Spring boot 与maven failsafe插件spring boot 1.4集成测试时出现TypeNotPresentExceptionProxy错误

Spring boot 与maven failsafe插件spring boot 1.4集成测试时出现TypeNotPresentExceptionProxy错误,spring-boot,integration-testing,maven-failsafe-plugin,Spring Boot,Integration Testing,Maven Failsafe Plugin,使用maven failsafe插件和spring boot 1.4运行集成测试时,我得到了ArrayStoreException:TypeNotPresentExceptionProxy 如果使用运行,则可以看到此错误 mvn-Pattach集成测试干净安装 我意识到,如果我将spring boot maven插件更改为在预集成测试阶段而不是包测试阶段运行,则不会发生错误 此外,这个错误是从我将spring boot升级到1.4时开始的。如果我将jsf spring boot父版本更改为使用s

使用maven failsafe插件和spring boot 1.4运行集成测试时,我得到了ArrayStoreExceptionTypeNotPresentExceptionProxy

如果使用运行,则可以看到此错误

mvn-Pattach集成测试干净安装

我意识到,如果我将spring boot maven插件更改为在预集成测试阶段而不是包测试阶段运行,则不会发生错误


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

我实际上在中找到了答案,简短的回答是maven failsafe插件与spring boot 1.4的新可执行布局不兼容。详细解释如下:

从故障保护2.19开始,
target/classes
不再在类路径上,并且 而是使用项目的内置jar。插件将无法运行 查找由于可执行jar布局中的更改而导致的类。 有两种方法可以解决此问题:

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

  • 配置
    springbootmaven插件
    重新打包
    目标。这样,原来的罐子就可以使用了 通过插件。例如:


org.springframework.boot
springbootmaven插件
执行官

此处记录了一个备选方案:


org.apache.maven.plugins
maven故障保护插件
${project.build.outputDirectory}

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

从SpringBoot 1.3升级到SpringBoot 1.4.0后,我遇到了完全相同的错误,我在使用mvn install failsafe:integration test运行故障保护集成测试时遇到错误,谢谢@Pom12-你救了我一天。我已经调试了8个小时了
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <classifier>exec</classifier>
    </configuration> 
</plugin>
<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>