さまざまな環境でMavenがパッケージ化したspringbootプロジェクト
1つは、環境構成です。
2. Pomは、「再パッケージ化」パッケージ化プラグインと「プロファイル」構成を追加します
//添加插件
<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>
3、application.yml構成
spring:
profiles:
active: @profileActive@
4、パッケージ
//默认local
mvn clean package
//dev环境
mvn clean package -P dev
//pro环境
mvn clean package -P pro