赞
踩
1、yml 文件:'@package.environment@'
or properties : @package.environment@
2、pom.xml
- <profiles>
- <!--开发环境-->
- <profile>
- <id>dev</id>
- <properties>
- <package.environment>dev</package.environment>
- </properties>
- <activation>
- <activeByDefault>true</activeByDefault>
- </activation>
- </profile>
- <!--测试环境-->
- <profile>
- <id>test</id>
- <properties>
- <package.environment>test</package.environment>
- </properties>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- </profile>
- <!--生产环境-->
- <profile>
- <id>prod</id>
- <properties>
- <package.environment>prod</package.environment>
- </properties>
- <activation>
- <activeByDefault>false</activeByDefault>
- </activation>
- </profile>
- </profiles>
- <build>
- <finalName>xxx</finalName>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- </resource>
- <resource>
- <directory>src/main/java</directory>
- <includes>
- <include>**/*.xml</include>
- </includes>
- </resource>
-
- <resource>
- <directory>src/main/resources</directory>
- <!-- 是否替换@xx@表示的maven properties属性值 -->
- <filtering>true</filtering>
- <includes>
- <include>application.properties</include>
- <include>application-${package.environment}.properties</include>
- </includes>
- </resource>
- </resources>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
开发工具:idea
记录一下,结束。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。