您好,登錄后才能下訂單哦!
本篇文章給大家分享的是有關(guān)如何解決SpringBoot打包jar運行時提示沒有主清單屬性問題,小編覺得挺實用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。
關(guān)于springboot打包成jar文件,然后運行java -jar命令時沒有主清單屬性問題,網(wǎng)上目前有好多種解決方案,而最尷尬的地方在于,不怎么好使,今天來搞兩種能用的。
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <phase>repackage</phase> </execution> </executions> </plugin> </plugins> </build>
然后
# 切換到子項目然后執(zhí)行打包命令 $ 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'
其實基本原理相同,都是先調(diào)用package然后調(diào)用了spring-boot:repackage的plugin,經(jīng)過實測,這兩種解決方案確實可以正確完成springboot的打包。
以上就是如何解決SpringBoot打包jar運行時提示沒有主清單屬性問題,小編相信有部分知識點可能是我們?nèi)粘9ぷ鲿姷交蛴玫降?。希望你能通過這篇文章學(xué)到更多知識。更多詳情敬請關(guān)注億速云行業(yè)資訊頻道。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。