【问题标题】:Spring Boot profiles not active when set with maven plugin使用 maven 插件设置时 Spring Boot 配置文件不活动
【发布时间】:2016-08-09 11:29:06
【问题描述】:

我正在尝试在启动 Tomcat 以在 maven 中进行集成测试时设置 spring 配置文件,如下所示:

...
<plugin>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-maven-plugin</artifactId>
  <executions>
    <execution>
      <id>pre-integration-test</id>
        <goals>
          <goal>start</goal>
        </goals>
        <configuration>
          <profiles>
            <profile>testProfile</profile>
          </profiles>
        </configuration>
...

个人资料肯定没有激活。

另一方面,以下操作确实有效,并且请求的配置文件处于活动状态:

<jvmArguments>-Dspring.profiles.active=testProfile</jvmArguments>

这里的问题是我们无法停止服务器,这是运行自动化集成测试时的问题。

我正在使用弹簧靴“1.4.0.RELEASE”。

我的问题: 1. 为什么profile标签不起作用? (漏洞?) 2. 为什么在“停止”目标中尝试关闭服务器时找不到 JMX bean?这是否与 jvmArguments 的分叉有关?

【问题讨论】:

    标签: spring-boot spring-boot-maven-plugin


    【解决方案1】:

    我忽略了 main 方法中的参数。将它们传递给 Spring 应用程序解决了它:

    public static void main(String[] args) throws Exception {
      SpringApplication.run(RunServer.class, args);
    }
    

    【讨论】:

      猜你喜欢
      • 2021-01-08
      • 2016-10-08
      • 1970-01-01
      • 2017-12-21
      • 2014-10-14
      • 2022-08-16
      • 2018-11-12
      • 1970-01-01
      • 2012-08-06
      相关资源
      最近更新 更多