pom:配置
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!--指定配置文件路径 -->
<profiles.dir>src/main/profiles</profiles.dir>
</properties>
<build>
<finalName>ROOT</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>${profile.dir}</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.yml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.yml</include>
</includes>
<!-- 是否替换资源中的属性-->
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
<!-- mybatis java code generator -->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
<verbose>true</verbose>
<overwrite>true</overwrite>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<!--开发环境配置文件 -->
<profile>
<id>dev</id>
<activation>
<property>
<name>environment.type</name>
<value>dev</value>
</property>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<profile.dir>${profiles.dir}/dev</profile.dir>
</properties>
</profile>
<!--测试环境配置文件 -->
<profile>
<id>test</id>
<properties>
<profile.dir>${profiles.dir}/test</profile.dir>
</properties>
</profile>
<!--生产环境配置文件 -->
<profile>
<id>product</id>
<properties>
<profile.dir>${profiles.dir}/product</profile.dir>
</properties>
</profile>
</profiles>