我们的应用程序构建在遗留的spring引导1和tomcat 7上,我们有两种类型的测试套件- Junits(Java)和Integration (用Groovy编写)。我们使用下面的插件来编译groovy测试。
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.2</version>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>${groovyVersion}</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<!-- testGenerateStubs allows us to reference Groovy classes from Java tests -->
<goal>testGenerateStubs</goal>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<testSources>
<testSource>
<directory>src/test/groovy</directory>
</testSource>
<testSource>
<directory>src/test-integration/java</directory>
<directory>src/test-integration/groovy</directory>
</testSource>
</testSources>
</configuration>
</plugin>我们最近对SpringBoot2.7.1进行了一次重大的升级,并正在删除不推荐的方法--代码重构等。我们几乎完成了它,但直到今天我们才发现gmavenplus插件的目标"testCompile“存在问题。它被抛在错误之下。
[INFO] --- gmavenplus-plugin:1.2:testCompile (default)
[INFO] Using Groovy 2.4.6 to perform testCompile.
[INFO] BUILD FAILURE
[ERROR] Failed to execute goal org.codehaus.gmavenplus:gmavenplus-plugin:1.2:testCompile (default) on project trta-tds: Error occurred while calling a method on a Groovy class from classpath.: InvocationTargetException: Unable to load class org.springframework.mock.web.MockHttpServletRequest due to missing dependency javax/servlet/http/HttpUpgradeHandler我们怀疑这可能是tomcat 7的问题,但我们仍然没有看到tomcat被用于"testCompile“目标。我们时间很紧。请让我们知道你的建议/解决方案。
发布于 2022-10-24 08:03:17
我也有过类似的问题。在我的例子中,帮助将javax.servlet-api更新为最新版本
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>https://stackoverflow.com/questions/73206503
复制相似问题