【发布时间】:2017-12-27 23:28:40
【问题描述】:
我在src/main/resources目录下有多组属性文件smtp、db、常用设置,我的项目是maven项目jar打包。我想从 jar 构建中排除所有这些属性文件,并将所有这些属性文件放到 target/conf 文件夹中。现在我想在执行应用程序 jar 时将所有这些配置文件提供给我的 jar。 如何做到这一点?我在 pom.xml 文件中做了几件事来排除所有这些属性,现在无法将它们提供给生成的 jar。 这是为了排除 src/main/resources 内容
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>*.properties</exclude>
</excludes>
<filtering>false</filtering>
</resource>
</resources>
Spring boot 插件配置
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
Maven资源插件将所有资源文件放在target/conf文件夹下
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>target/conf</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
【问题讨论】:
-
请向我们展示您所做的工作。 “几件事”是行不通的。
标签: maven spring-boot