您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
本篇文章给大家分享的是有关如何解决SpringBoot打包jar运行时提示没有主清单属性问题,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
关于springboot打包成jar文件,然后运行java -jar命令时没有主清单属性问题,网上目前有好多种解决方案,而最尴尬的地方在于,不怎么好使,今天来搞两种能用的。
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <phase>repackage</phase> </execution> </executions> </plugin> </plugins> </build>
然后
# 切换到子项目然后执行打包命令 $ cd test-package & mvn package
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
巧用IDEA,先选中该项目,然后
$ java -jar test-package-1.0-SNAPSHOT.jar . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| | ) ) ) ) ' |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.3.3.RELEASE) 2020-09-28 16:58:08.980 INFO 23124 --- [ main] test.PackageApplication : Starting PackageApplication on DESKTOP-4G39J2B with PID 23124 (\demo-project\test-package\target\test-package-1.0-SNAPSH OT.jar started by idea in \demo-project\test-package\target) 2020-09-28 16:58:08.983 INFO 23124 --- [ main] test.PackageApplication : No active profile set, falling back to default profiles: default 2020-09-28 16:58:09.937 INFO 23124 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2020-09-28 16:58:09.951 INFO 23124 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2020-09-28 16:58:09.951 INFO 23124 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.37] 2020-09-28 16:58:10.017 INFO 23124 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2020-09-28 16:58:10.017 INFO 23124 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 977 ms 2020-09-28 16:58:10.172 INFO 23124 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor' 2020-09-28 16:58:10.323 INFO 23124 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' 2020-09-28 16:58:10.331 INFO 23124 --- [ main] test.PackageApplication : Started PackageApplication in 1.7 seconds (JVM running for 2.068) 2020-09-28 16:59:52.704 INFO 23124 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
其实基本原理相同,都是先调用package然后调用了spring-boot:repackage的plugin,经过实测,这两种解决方案确实可以正确完成springboot的打包。
以上就是如何解决SpringBoot打包jar运行时提示没有主清单属性问题,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。