您好,登錄后才能下訂單哦!
本篇文章給大家分享的是有關如何解決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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。