我有一个战争文件,其默认资源为application.properties
。我想在Tomcat上部署时,将这些属性放到/webapps/example
之类的外部文件夹中,而不是/webapps/namewar
。
我可以配置我的Maven或做些什么来实现该目标吗?
非常感谢您。
答案 0 :(得分:0)
您可以使用maven-resources-plugin的copy-resources目标将文件从源树复制到某个目录。您需要在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>