我有一个 Spring Boot Maven 多模块项目。
如果spring boot模块依赖模块A
并在src/main/resources
模块文件夹A
我想在最终的 Spring Boot 应用程序中捆绑一个属性文件或其他一些资源,我该如何实现这一点。
目前,如果我跑jar -tf
在模块 A JAR 上,它包含以下文件:
jar -tf module-a/target/module-a-0.0.1-SNAPSHOT.jar | grep changelog
db/changelog/
db/changelog/db.changelog-master.yaml
However:
jar -tf boot-module/target/boot-module-0.0.1-SNAPSHOT.jar | grep changelog | wc -l
0
预先感谢您的任何建议。
如果我正确理解您的要求,我相信您可以使用unpack
的目标maven-dependency-plugin
在你的 Spring Boot 模块中:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>module-a</artifactId>
<version>${project.version}</version>
<includes>**/*.yaml</includes>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/classes/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
这将从中复制资源module-a
to boot-module
。我已经发布了一个完整的例子GitHub https://github.com/jjlharrison/copy-resources-example.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)