参考 :https://blog.csdn.net/top_code/article/details/78570047
附上pom的 profiles配置
<build> <finalName>${project.artifactId}</finalName> <resources> <resource> <directory>src/main/resources/</directory> <filtering>true</filtering> </resource> </resources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <encoding>utf-8</encoding> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> <profiles> <profile> <id>dev</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <profilesActive>dev</profilesActive> </properties> </profile> <profile> <id>test</id> <properties> <profilesActive>test</profilesActive> </properties> </profile> <profile> <id>prod</id> <properties> <profilesActive>prod</profilesActive> </properties> <build> <filters> <filter>/Users/xxx/Desktop/prod.properties</filter> </filters> </build> </profile> </profiles>