- 目录结构
- 在pom.xml中添加如下profile的配置:
<!--多环境配置-->
<profiles>
<profile>
<!-- 本地开发环境 -->
<id>local</id>
<properties>
<profiles.active>local</profiles.active>
<!--<deploy.url>http://host:port/manager/text</deploy.url>-->
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<!-- 测试环境 -->
<id>test</id>
<properties>
<profiles.active>test</profiles.active>
<!--<deploy.url>http://host:port/manager/text</deploy.url>-->
</properties>
</profile>
<profile>
<!-- 生产环境 -->
<id>prod</id>
<properties>
<profiles.active>prod</profiles.active>
<!--<deploy.url>http://host:port/manager/text</deploy.url>-->
</properties>
</profile>
</profiles>
-
当加入这些配置后就能在右侧看到目录如下:
- 配置指向的目录(在<build>下配置如下):
<resources>
<resource>
<directory>src/main/resources</directory>
<!-- 资源根目录排除各环境的配置,使用单独的资源目录来指定 -->
<excludes>
<exclude>test/*</exclude>
<exclude>prod/*</exclude>
<exclude>local/*</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources/${profiles.active}</directory>
</resource>
</resources>