Spring Boot创建非可执行jar包的实例教程

网友投稿 274 2023-02-19


Spring Boot创建非可执行jar包的实例教程

我们经常会有这种场景,只需要把Spring Boot打成普通的jar包,不包含配置文件,供其他程序应用

本文介绍如何使用Maven将Spring Boot应用打成普通的非可执行jar包。

配置maven-jar-plugin

org.springframework.boot

spring-boot-maven-plugin

exec

maven-jar-plugin

exec

package

jar

exec

package

jar

true

application.yml

执行mvn clean package打包

localhost:spring-boot-tutorial-non-executable majunwei$ mvn clean package

[INFO] Scanning for projects...

[WARNING]

[WARNING] Some problems were encountered while building the effective model for com.majunwei:spring-boot-tutorial-non-executable:jar:0.0.1-SNAPSHOT

[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. @ com.majunwei:spring-boot-tutorial-non-executable:[unknown-version], /Users/majunwei/Documents/work/spring-boot-tutorial/spring-boot-tutorial-non-executable/pom.xml, line 26, column 17

[WARNING] 'build.plugins.plugin.version' for org.springframework.boot:spring-boot-maven-plugin is missing. @ com.majunwei:spring-boot-tutorial-non-executable:[unknown-version], /Users/majunwei/Documents/work/spring-boot-tutorial/spring-boot-tutorial-non-executable/pom.xml, line 19, column 17

[WARNING]

[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.

[WARNING]

[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.

[WARNING]

[INFO] http://

[INFO] ------------------------------------------------------------------------

[INFO] Building spring-boot-tutorial-non-executable 0.0.1-SNAPSHOT

[INFO] ------------------------------------------------------------------------

[INFO]

[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ spring-boot-tutorial-non-executable ---

[INFO] Deleting /Users/majunwei/Documents/work/spring-boot-tutorial/spring-boot-tutorial-non-executable/target

[INFO]

[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ spring-boot-tutorial-non-executable ---

[INFO] Using 'UTF-8' encoding to copy filtered resources.

[INFO] Copying 1 resource

[INFO]

[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ spring-boot-tutorial-non-executable ---

[INFO] Changes detected - recompiling the module!

[INFO] Compiling 1 source file to /Users/majunwei/Documents/work/spring-boot-tutorial/spring-boot-tutorial-non-executable/target/classes

[INFO]

[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ spring-boot-tutorial-non-executable ---

[INFO] Using 'UTF-8' encoding to copy filtered resources.

[INFO] skip non existing resourceDirectory /Users/majunwei/Documents/work/spring-boot-tutorial/spring-boot-tutorial-non-executable/src/test/resources

[INFO]

[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ spring-boot-tutorial-non-executable ---

[INFO] Nothing to compile - all classes are up to date

[INFO]

[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ spring-boot-tutorial-non-executable ---

[INFO] No tests to run.

[INFO]

[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ spring-boot-tutorial-non-executable ---

[INFO] Building jar: /Users/majunwei/Documents/work/spring-boot-tutorial/spring-boot-tutorial-non-executable/target/spring-boot-tutorial-non-executable-0.0.1-SNAPSHOT.jar

[INFO]

[INFO] --- maven-jar-plugin:2.4:jar (exec) @ spring-boot-tutorial-non-executable ---

[INFO] Building jar: /Users/majunwei/Documents/work/spring-boot-tutorial/spring-boot-tutorial-non-executable/target/spring-boot-tutorial-non-executable-0.0.1-SNAPSHOT-exec.jar

[INFO]

[INFO] --- maven-jar-plugin:2.4:jar (default) @ spring-boot-tutorial-non-executable ---

[INFO] Building jar: /Users/majunwei/Documents/work/spring-boot-tutorial/spring-boot-tutorial-non-executable/target/spring-boot-tutorial-non-executable-0.0.1-SNAPSHOT.jar

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 2.692 s

[INFO] Finished at: 2017-08-07T18:22:50+08:00

[INFO] Final Memory: 17M/174M

[INFO] ------------------------------------------------------------------------

下载实例源码


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:调用dubbo接口测试(Dubbo接口)
下一篇:局域网f盘文件夹共享设置(局域网磁盘共享后怎么访问)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~