使用maven-failsafe-plugin spring-boot 1.4进行集成测试时出现TypeNotPresentExceptionProxy错误

Mar*_*des 9 integration-testing maven-failsafe-plugin spring-boot

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

如果运行joinfaces-example,则可以看到此错误

mvn -Pattach-integration-test clean install

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

此外,当我将spring boot升级到1.4时,此错误开始了.如果我将jsf-spring-boot-parent版本更改为使用spring boot 1.3版本的2.0.0,则不会发生错误.

Pom*_*m12 14

我实际上在Spring Boot 1.4发行说明中找到了答案,简短的回答是maven-failsafe-plugin与Spring Boot 1.4新的可执行文件布局不兼容.完整说明如下:

截止Failsafe 2.19,target/classes不再在类路径上,而是使用项目的构建jar.由于可执行jar布局的更改,插件将无法找到您的类.有两种方法可以解决此问题:

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

  • 配置spring-boot-maven-pluginrepackage目标使用分类器 .这样,原始jar将可用并由插件使用.例如 :

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <classifier>exec</classifier>
    </configuration> 
</plugin>
Run Code Online (Sandbox Code Playgroud)


Fle*_*tch 7

此处记录了另一种选择: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>
Run Code Online (Sandbox Code Playgroud)

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