Java Maven测试在终端上失败,但在IntelliJ中通过

Java Maven测试在终端上失败,但在IntelliJ中通过,java,maven,intellij-idea,Java,Maven,Intellij Idea,我的Spring Boot应用程序使用TestNG,它有surefire插件。我试图在终端上打包它,但它在maven测试步骤上一直失败。如果我在IntelliJ上运行maven package命令,那么所有maven步骤都可以正常运行并通过 当它试图在终端/命令行上进行mvn测试时,我只收到如下错误。可能是什么?我认为这是一个Mockito依赖性问题,但即使在我的pom.xml中添加了它,也没有任何变化 You can learn about inline mocks and their lim

我的Spring Boot应用程序使用TestNG,它有surefire插件。我试图在终端上打包它,但它在maven测试步骤上一直失败。如果我在IntelliJ上运行maven package命令,那么所有maven步骤都可以正常运行并通过

当它试图在终端/命令行上进行
mvn测试时,我只收到如下错误。可能是什么?我认为这是一个Mockito依赖性问题,但即使在我的pom.xml中添加了它,也没有任何变化

You can learn about inline mocks and their limitations under item #39 of the Mockito class javadoc.

Underlying exception : org.mockito.exceptions.base.MockitoException: Could not modify all classes [class java.lang.Object, class org.fluentd.logger.FluentLogger]
    at com.homedepot.appconfig.error.reporting.StackDriverErrorReporterTest.reportError_WithHttpRequest_False(StackDriverErrorReporterTest.java:112)
Caused by: org.mockito.exceptions.base.MockitoException: Could not modify all classes [class java.lang.Object, class org.fluentd.logger.FluentLogger]
    at com.homedepot.appconfig.error.reporting.StackDriverErrorReporterTest.reportError_WithHttpRequest_False(StackDriverErrorReporterTest.java:112)
Caused by: java.lang.IllegalStateException: 

Byte Buddy could not instrument all classes within the mock's type hierarchy

This problem should never occur for javac-compiled classes. This problem has been observed for classes that are:
 - Compiled by older versions of scalac
 - Classes that are part of the Android distribution
    at com.homedepot.appconfig.error.reporting.StackDriverErrorReporterTest.reportError_WithHttpRequest_False(StackDriverErrorReporterTest.java:112)
Caused by: java.lang.IllegalArgumentException
    at com.homedepot.appconfig.error.reporting.StackDriverErrorReporterTest.reportError_WithHttpRequest_False(StackDriverErrorReporterTest.java:112)
Mockito cannot mock this class:```



检查maven版本和它选择运行测试的pom.xml文件;这是我的猜测。

检查maven版本和它选择运行测试的pom.xml文件;这是我的猜测。

请按照此链接编辑您的问题@大卫,你能解决这个问题吗?我遇到了完全相同的问题。我正在使用jdk 11、junit juniper 5.3.2、mockito junit jupiter 2.24.0和mockito core 2.24.4。当我在IntelliJ中运行时,我的测试通过,但在终端上失败,出现了您收到的错误。请按照此链接编辑您的查询@大卫,你能解决这个问题吗?我遇到了完全相同的问题。我正在使用jdk 11、junit juniper 5.3.2、mockito junit jupiter 2.24.0和mockito core 2.24.4。当我在IntelliJ中运行时,我的测试通过了,但在终端上失败了,出现了错误。因此,使用
mvn-version
我得到了
ApacheMaven 3.6.0
,但是查看pom.xml,我看到
3.8.0
对于
Maven编译器插件
这可能是不匹配的问题吗?所以使用
mvn-version
我得到了答案
apachemaven 3.6.0
但是查看pom.xml,我看到
Maven编译器插件的
3.8.0
,这可能是不匹配的问题吗?