【问题标题】:Spring boot upgrade - codehaus gmavenplus-plugin throwing missing dependency javax.servlet.http.HttpUpgradeHandler exceptionSpring boot 升级-codehaus gmavenplus-plugin 抛出缺少依赖 javax.servlet.http.HttpUpgradeHandler 异常
【发布时间】:2022-10-24 16:03:17
【问题描述】:

我们的应用程序基于传统的 spring boot 1 和 tomcat 7 构建。我们有 2 种类型的测试套件 - Junits(Java)和集成测试(用 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>

我们最近对 Spring Boot 2.7.1 进行了重大升级,并正在删除不推荐使用的方法 - 代码重构等。我们几乎完成了它,但直到今天才发现 gmavenplus-plugin 的目标“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”目标。我们的时间紧迫。请让我们知道您的建议/解决方案。

【问题讨论】:

    标签: java spring spring-boot maven groovy


    【解决方案1】:

    我有一个类似的问题。在我的情况下,有助于将 javax.servlet-api 更新到最新版本

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>4.0.1</version>
        <scope>provided</scope>
    </dependency>
    

    【讨论】:

      猜你喜欢
      • 2017-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-13
      • 2016-09-26
      • 2019-09-19
      • 2014-04-18
      • 2016-12-21
      相关资源
      最近更新 更多