【发布时间】:2021-12-27 18:01:56
【问题描述】:
我在我的 maven pom 中获得了以下个人资料:
<profiles>
<profile>
<id>local</id>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<profiles>
<profile>local</profile>
</profiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
这对于启动应用程序来说很好,但是如果我想按以下方式构建应用程序
mvn clean install -Plocal
我的@SpringBootTest 失败是因为:
No active profile set, falling back to default profiles: default
也试过了:
<profile>
<id>local</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<argLine>-Dspring.profiles.active=local</argLine>
</configuration>
</plugin>
</plugins>
</build>
</profile>
我错过了什么?
ps mvn spring-boot:run -Plocal 在那里工作没问题...
也没有兴趣
mvn clean install -Dspring.profiles.active=local 我知道这是可行的,但只是不感兴趣,因为配置文件包含的不仅仅是我们的配置文件!
【问题讨论】:
-
为什么使用与 maven 配置文件相关的 spring boot 配置文件。没有意义...如果您想使用配置文件启动 Spring Boot 应用程序,请通过
--spring.profiles.active=XXX使用命令行...
标签: spring-boot maven maven-3 spring-boot-maven-plugin