我在默认资源中有一个带有application.properties
的战争文件。我想在tomcat上部署时,将这些属性放入诸如/webapps/example
的外部文件夹中,而不是/webapps/namewar
。
我可以配置我的小男人还是做点什么才能实现?
非常感谢。
您可以使用maven-resources-plugin的复制资源目标将文件从源树复制到某个目录。您需要在pom.xml中添加类似以下内容:
<project>
...
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- you may want to choose another phase -->
<!-- see https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<!-- outputDirectory can be absolute or relative to ${basedir} -->
<outputDirectory>/webapps/example</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory><!-- or whereever your application.properties reside -->
<includes>
<include>application.properties</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
...
</build>
...
</project>