问题描述
我正在使用jetty-runner.jar部署一个Spring MVC应用程序到Heroku,但是在部署中出现错误。
Heroku日志只显示:
解决您的 maven-clean-plugin 正在删除中的 jar 当您尝试在 Heroku 上构建您的应用程序时,请执行以下操作:c> dependency directory和其他所需的目录。
您可以在 pom.xml 中删除 maven-clean-plugin ,或者修改它。
最佳选择是删除pom.xml中的插件
< plugin>
< artifactId> maven-clean-plugin< / artifactId>
< version> 2.5< / version>
<执行次数>
<执行>
< id> clean-jar-artifacts< / id>
<阶段>安装< /阶段>
<目标><目标>清洁< /目标>< /目标>
<配置>
< excludeDefaultDirectories> true< / excludeDefaultDirectories>
<档案集>
< fileset>
<目录>目标< /目录>
< exclude> *。war< / exclude>
< /不包括>
< / fileset>
< / filesets>
< / configuration>
< /执行>
< /执行次数>
< / plugin>
或者您可以排除依赖项/ *。jar $ c $通过简单地添加下面指定的< exclude> ..< / exclude> 标签来删除。但是这个选项可能会删除成功部署应用程序所需的其他必需文件夹。所以我不会推荐这个。
< plugin>
< artifactId> maven-clean-plugin< / artifactId>
< version> 2.5< / version>
<执行次数>
<执行>
< id> clean-jar-artifacts< / id>
<阶段>安装< /阶段>
<目标>
< goal> clean< / goal>
< /目标>
<配置>
< excludeDefaultDirectories> true< / excludeDefaultDirectories>
<档案集>
< fileset>
<目录>目标< /目录>
< exclude> *。war< / exclude>
< exclude>依赖项/ *。jar< / exclude>
< /不包括>
< / fileset>
< / filesets>
< / configuration>
< /执行>
< /执行次数>
< / plugin>
看看获取更多信息。
I'm deploying a Spring MVC app to Heroku using jetty-runner.jar, but I get an error in the deployment.The Heroku logs only show:
Error: unable to access jarfile target/dependency/jetty-runner.jar State changed from starting to crashed Process exited with status 1However, the app is working correctly if I run it locally using either:
heroku local web -f Procfile.windowsor
java -jar target\dependency\jetty-runner.jar target\*.warThe file under "target/dependency/jetty-runner.jar" is created correctly in my computer when running the "mvn package" command.
My Procfile looks like this:
web: java $JAVA_OPTS -jar target/dependency/jetty-runner.jar --port $PORT target/*.warMy pom.xml file and project code are located in:https://github.com/gfigueroa/nlp-tools-spring-heroku
ADDITIONAL DETAILS
I ran the command heroku run ls target after deploying and it only shows the .war file. The dependency folder was not created when deploying, even though it was when I packaged my project locally.
解决方案Your maven-clean-plugin is deleting the jar file in dependency directory and other required directories when you try to build your app on Heroku.
You can either remove the maven-clean-plugin in the pom.xml or you can modify it.
Best option is to remove the plugin below in pom.xml
<plugin> <artifactId>maven-clean-plugin</artifactId> <version>2.5</version> <executions> <execution> <id>clean-jar-artifacts</id> <phase>install</phase> <goals><goal>clean</goal></goals> <configuration> <excludeDefaultDirectories>true</excludeDefaultDirectories> <filesets> <fileset> <directory>target</directory> <excludes> <exclude>*.war</exclude> </excludes> </fileset> </filesets> </configuration> </execution> </executions> </plugin>Or you can exclude the dependency/*.jar from deleting by simply adding the <exclude>..</exclude> tags as specified below. But this option might delete other required folders which are necessary for deploying the app successfully. So I would not recommend this.
<plugin> <artifactId>maven-clean-plugin</artifactId> <version>2.5</version> <executions> <execution> <id>clean-jar-artifacts</id> <phase>install</phase> <goals> <goal>clean</goal> </goals> <configuration> <excludeDefaultDirectories>true</excludeDefaultDirectories> <filesets> <fileset> <directory>target</directory> <excludes> <exclude>*.war</exclude> <exclude>dependency/*.jar</exclude> </excludes> </fileset> </filesets> </configuration> </execution> </executions> </plugin>Look at this page for more information.
这篇关于Heroku无法访问jetty-runner jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-15 01:01