Maven packaged springboot projects in different environments
One, environment configuration
![enter description here](https://img-blog.csdnimg.cn/img_convert/4cd55a3bd9df59d850dfcba9d4c1802c.png)
2. Pom adds "repackage" packaged plug-in and "profiles" configuration
//添加插件
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
//添加profiles
<profiles>
<profile>
<id>local</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<spring.profiles.active>local</spring.profiles.active>
<profileActive>local</profileActive>
</properties>
</profile>
<profile>
<id>dev</id>
<properties>
<spring.profiles.active>dev</spring.profiles.active>
<profileActive>dev</profileActive>
</properties>
</profile>
<profile>
<id>pro</id>
<properties>
<spring.profiles.active>pro</spring.profiles.active>
<profileActive>pro</profileActive>
</properties>
</profile>
</profiles>
Three, application.yml configuration
spring:
profiles:
active: @profileActive@
Four, packaging
//默认local
mvn clean package
//dev环境
mvn clean package -P dev
//pro环境
mvn clean package -P pro