【问题标题】:Maven spring boot pre-integration-test timeout errorMaven spring boot预集成-测试超时错误
【发布时间】:2017-07-31 23:33:01
【问题描述】:

当我运行服务器生命周期的命令 install 时,我收到以下错误:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 34.507 s
[INFO] Finished at: 2017-03-10T15:32:41+01:00
[INFO] Final Memory: 69M/596M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.0.RELEASE:start (pre-integration-test) on project challenger-server-boot: Spring application did not start before the configured timeout (30000ms -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

这显然来自超时设置,但我找不到必须更改此值的位置...

不确定它是否有帮助,但这是我的一些与单元和集成测试相关的 pom.xml:

    <!-- Unit testing -->
    <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
            <skipTests>true</skipTests>
        </configuration>
    </plugin>

    <!-- Integration testing -->
    <plugin>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>2.19.1</version>
        <configuration>
            <skipTests>false</skipTests>
        </configuration>
    </plugin>

这里是调试日志:http://pastebin.com/kUkufHFS

【问题讨论】:

  • 您能否重新运行您的 maven 语句并添加 -X 以进行调试日志记录以获取更多信息?谢谢您可以将完整的调试日志粘贴到一些在线粘贴文本,粘贴箱,例如:pasted.co
  • 您为什么要尝试定义已经属于 maven-surefire-plugin 和 maven-failsafe-plugin 的命名约定。无需为 maven-surefire-plugin 排除 **/*IT.java 或将它们包含在 maven-failsafe-plugin 中...
  • @LamLe:我在问题中添加了调试日志
  • @khmarbaise 我不知道,谢谢提供信息

标签: spring maven spring-boot


【解决方案1】:

您正尝试在预集成测试阶段之前启动 Spring Boot 应用程序。 spring-boot-maven-plugin StartMojo 类(org.springframework.boot.maven)抱怨,因为应用程序没有在默认超时内启动,这由属性“wait”(默认值:500 ms)和“ maxAttempts”(默认:60)-> 500 * 60。

/**
 * The number of milli-seconds to wait between each attempt to check if the spring
 * application is ready.
 */
@Parameter
private long wait = 500;

/**
 * The maximum number of attempts to check if the spring application is ready.
 * Combined with the "wait" argument, this gives a global timeout value (30 sec by
 * default)
 */
@Parameter
private int maxAttempts = 60;

“wait”和“maxAttempts”被注解@Parameter,这意味着你可以在你的pom文件中改变它们的值,在插件配置中像这样:

<plugin>
     <groupId>org.springframework.boot</groupId>
     <artifactId>spring-boot-maven-plugin</artifactId>
     <configuration>
              <wait>1000</wait>
              <maxAttempts>180</maxAttempts>
     </configuration>
     <executions>
              ...
     </executions> 
</plugin>

【讨论】:

    猜你喜欢
    • 2019-07-30
    • 2016-01-21
    • 2019-12-27
    • 2016-12-08
    • 2020-02-25
    • 1970-01-01
    • 2018-11-24
    • 1970-01-01
    • 2015-08-20
    相关资源
    最近更新 更多