【问题标题】:TypeNotPresentExceptionProxy error at integration-test with maven-failsafe-plugin spring-boot 1.4使用 maven-failsafe-plugin spring-boot 1.4 进行集成测试时出现 TypeNotPresentExceptionProxy 错误
【发布时间】:2016-12-08 03:46:18
【问题描述】:

在使用 maven-failsafe-plugin 和 spring-boot 1.4 运行集成测试时,我收到 ArrayStoreException: TypeNotPresentExceptionProxy

如果你运行joinfaces-example 会看到这个错误

mvn -Pattach-integration-test 全新安装

我意识到,如果我将 spring-boot-maven-plugin 更改为在 pre-integration-test 阶段而不是 package 阶段运行,则不会发生错误。

更多,这个错误是在我将 spring boot 升级到 1.4 时开始的。如果我将 jsf-spring-boot-parent 版本更改为使用 spring boot 1.3 版本的 2.0.0,则不会发生错误。

【问题讨论】:

  • 从 SpringBoot 1.3 升级到 SpringBoot 1.4.0 后出现完全相同的错误,使用 mvn install failsafe:integration-test 运行故障安全集成测试时出现错误

标签: spring-boot integration-testing maven-failsafe-plugin


【解决方案1】:

其实我在Spring Boot 1.4 release notes 中找到了答案,简短的回答是maven-failsafe-plugin 与Spring Boot 1.4 的新可执行布局不兼容。完整解释如下:

截至Failsafe 2.19target/classes 不再位于类路径中,并且 而是使用项目构建的 jar。该插件将无法 由于可执行 jar 布局的变化,找到你的类。 有两种方法可以解决此问题:

  • 降级到2.18.1,以便您改用目标/类

  • spring-boot-maven-plugin 配置为使用分类器 repackage 目标。这样,原始 jar 将可用并使用 通过插件。例如:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <classifier>exec</classifier>
    </configuration> 
</plugin>

【讨论】:

  • 谢谢@Pom12 - 你拯救了我的一天。我已经调试了大约 8 个小时了
  • 你拯救了我的一天。非常感谢
【解决方案2】:

此处记录了另一种选择:https://github.com/spring-projects/spring-boot/issues/6254

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <!--
        Make failsafe and spring-boot repackage play nice together,
        see https://github.com/spring-projects/spring-boot/issues/6254
    -->
    <configuration>
        <classesDirectory>${project.build.outputDirectory}</classesDirectory>
    </configuration>
</plugin>

这对我来说效果更好,因为当我使用“exec”解决方案时,Spring 在启动容器时找不到我的配置文件。我想这可能可以通过添加一些进一步的配置参数来解决,但是这个解决方案对我来说是“开箱即用”的。

【讨论】:

    猜你喜欢
    • 2016-12-30
    • 2019-05-08
    • 1970-01-01
    • 2018-08-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-29
    • 2018-03-05
    相关资源
    最近更新 更多