首先这段是给mvn用来指定哪个环境的,尽管这里写了默认dev生效,但是最终决定权还在mvn手里
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<package.environment>config/dev</package.environment>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<package.environment>config/test</package.environment>
</properties>
</profile>
<profile>
<id>product</id>
<properties>
<package.environment>config/product</package.environment>
</properties>
</profile>
</profiles>
下面这个插件是mvn帮助我们将指定环境配置文件拷贝到target下的classes目录,需要手动运行compile或者install才会执行
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<overwrite>true</overwrite>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<resources>
<resource>
<directory>src/main/resources/${package.environment}</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
所以如果不执行那两个mvn命令配置文件是不会做拷贝的,也就不会生效,切记!!! |