この種のシナリオがよくあることがよくあります。他のプログラムを適用するために、構成ファイルなしで、Spring Bootを通常のJARパッケージにするだけです
この記事では、Mavenを使用してSpring Bootアプリケーションを通常の実行不可能なJARパッケージに作成する方法について説明します。
Maven-Jar-Pluginを構成します
<build> <plugins> <plugin> <groupid> org.springframework.boot </groupid> <artifactid> spring-boot-maven-plugin </artifactid> <configuration> <configuration> <classifier> exec </classifier> </configuration> </plugin> <plugin> maven-jar-plugin </artificin <id> exec </id> <phase>パッケージ</phase> <gogle> jar </goal> </goal> </goal> <configuration> <classifier> exec </classifier> </configuration> </configution> </execution> <phase> phase> <goal> <goal> jar </goal> </<configuration> < <ForceCreation> true </forceCreation> <expludes> <explude> application.yml </explude> </expludes> </configuration> </execution> </executions> </plugin> </plugins> </build>
MVNクリーンパッケージを実行します
LocalHost:Spring-Boot-Tutorial-Non-Executable Majunwei $ MVNクリーンパッケージ[情報]プロジェクトのスキャン... [警告] [警告] com.majunweiの効果的なモデルの構築中にいくつかの問題が発生しました:spring-boot-tutorial-non-executable:jar:jar:0.0.1-snapshot [警告] org.apache.maven.plugins:maven-jar-pluginが欠落しています。 @ com.majunwei:spring-boot-tutorial-non-executable:[unknown-version]、/users/majunwei/documents/work/spring-boot-tutorial/spring-boot-tutorial-non-xexecutable/pom.xml、line 26、columm org.springframework.boot:spring-boot-maven-pluginがありません。 @ com.majunwei:spring-boot-tutorial-non-executable:[unknown-version]、/users/majunwei/documents/work/spring-boot-tutorial/spring-boot-tutorial-non-xecutable/pom.xml、line 19、列17 [警告] [情報] [情報] -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- /users/majunwei/documents/work/spring-boot-tutorial/spring-boot-tutorial-non-executable/executable [info] [info] --- maven-resources-plugin:2.6:spring-boot-tutorial-non-executable --- [info] 'utf-8' necoding [info] inful] infulting [Info]を使用して、spring-boot-tutorial-non-executable --- [info] --- Maven-Compiler-Plugin:3.1:Compile(Default-Compile) @ Spring-Boot-Tutorial-Non-Executable --- [info]変更された変更 - モジュールの再コンパイル! Maven-Resources-Plugin:2.6:testResources(default-testResources) @ spring-boot-tutorial-non-executable --- [info] 'utf-8'エンコーディングを使用してフィルタリングされたリソースをコピーします。 /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- Maven-Surefire-Plugin:2.12.4:test(default-test) @ spring-boot-tutorial-non-executable - [info]実行するテストはありません。 /users/majunwei/work/spring-boot-tutorial/spring-boot-tutorial-non-executable/target/spring-boot-tutorial-non-executable-0.0.0.1-snapshot.jar Spring-boot-tutorial-non-executable --- [info] Building Jar:/users/majunwii/documents/work/spring-boot-tutorial/spring-boot-tutorial-non-executable/target/spring-boot-tutorial-non-executable-0.0. Maven-Jar-Plugin:2.4:Jar(default) @ spring-boot-tutorial-non-executable --- [info]ビルディングジャー: /users/majunwei/work/spring-boot-tutorial/spring-boot-tutorial-non-executable/target/spring-boot-tutorial-non-executable-0.0.1-snapshot.jar_info] ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ 2017-08-07T18:22:50+08:00[INFO] Final Memory: 17M/174M[INFO] ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
インスタンスソースコードをダウンロードします
上記はこの記事のすべての内容です。みんなの学習に役立つことを願っています。誰もがwulin.comをもっとサポートすることを願っています。