即使在未对源代码进行任何修改的情况下,在带有资源目录的spring boot应用程序上运行“ mvn软件包”,也始终会重新打包整个模块。
要重现此问题,请运行以下说明:
现在添加资源目录和application.properties文件:
并重新运行测试:
ls -l --time-style ='+%d-%m-%Y%H:%M:%S'target / *。jar
等待几秒钟
mvn软件包
Maven的输出是这样的:
mario@PRS-NB-005# mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building gs-spring-boot 0.1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ gs-spring-boot ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ gs-spring-boot ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ gs-spring-boot ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /mario/prj/web/bbb/gs-spring-boot/initial/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.7.0:testCompile (default-testCompile) @ gs-spring-boot ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ gs-spring-boot ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) @ gs-spring-boot ---
[INFO] Building jar: /mario/prj/web/bbb/gs-spring-boot/initial/target/gs-spring-boot-0.1.0.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:2.0.5.RELEASE:repackage (default) @ gs-spring-boot ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.337 s
[INFO] Finished at: 2019-02-08T00:29:43+01:00
[INFO] Final Memory: 22M/308M
[INFO] ------------------------------------------------------------------------
答案 0 :(得分:1)
看看有效的pom。 在那里,您将看到以下内容:
<build>
...
<resources>
<resource>
<filtering>true</filtering>
<directory>path/gs-spring-boot/initial/src/main/resources</directory>
<includes>
<include>**/application*.yml</include>
<include>**/application*.yaml</include>
<include>**/application*.properties</include>
</includes>
</resource>
...
由于<filtering>true</filtering>
,它与每个mvn package
一起创建了罐子。
此配置来自:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
</parent>
如果不需要对application.properties进行过滤,则可以从头开始在pom.xml中覆盖。