【问题标题】:Spring boot 2.2 activemq jetty conflictSpring boot 2.2 activemq码头冲突
【发布时间】:2020-04-04 18:26:23
【问题描述】:

我正在尝试将 Spring boot 与 jetty starter 一起升级到 2.2 版。 由于码头版本冲突,我收到这些错误 以下方法不存在:

'org.eclipse.jetty.websocket.server.NativeWebSocketConfiguration org.eclipse.jetty.websocket.server.NativeWebSocketServletContainerInitializer.initialize(org.eclipse.jetty.servlet.ServletContextHandler)'

该方法的类 org.eclipse.jetty.websocket.server.NativeWebSocketServletContainerInitializer 可从以下位置获得:

jar:file:/some-dir/target/p3.0.166-SNAPSHOT.war!/WEB-INF/lib/jetty-all-9.4.19.v20190610-uber.jar!/org/eclipse/jetty/websocket/server/NativeWebSocketServletContainerInitializer.class
jar:file:/some-dir/target/p3.0.166-SNAPSHOT.war!/WEB-INF/lib/websocket-server-9.4.20.v20190813.jar!/org/eclipse/jetty/websocket/server/NativeWebSocketServletContainerInitializer.class

我有 activemq 依赖项,它引入了它自己的 jetty-all 版本 9.4.19 依赖项,这与 spring-boot 2.2 jetty (9.4.20) 冲突

我的 pom.xml 的一部分是:

       <dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jetty</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
            <!--
        Jsp-api isn't standard in spring boot
    -->
    <dependency>
        <groupId>javax.servlet.jsp</groupId>
        <artifactId>javax.servlet.jsp-api</artifactId>
        <version>${jsp.version}</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <scope>provided</scope>
    </dependency>

    <!-- artefacts enable JSP running in spring-boot -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>apache-jsp</artifactId>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>apache-jstl</artifactId>
    </dependency>

    <!--
        Used to be a single artifact.
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
        Newer versions splits the interface and implementation.
        This suggests to use a Glassfish implementation.
        https://www.andygibson.net/blog/quickbyte/jstl-missing-from-maven-repositories/
        The one we used had an Apache implementation, so going with that.
        https://stackoverflow.com/a/24444342
        -->
    <dependency>
        <groupId>org.apache.taglibs</groupId>
        <artifactId>taglibs-standard-spec</artifactId>
        <version>${taglibs.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.taglibs</groupId>
        <artifactId>taglibs-standard-impl</artifactId>
        <version>${taglibs.version}</version>
    </dependency>
            <!-- Unit test dependencies -->
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.easytesting</groupId>
        <artifactId>fest-assert</artifactId>
        <version>1.4</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-core</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <scope>test</scope>
    </dependency>

    <!-- html compressing is used by hrmanager in the JSP -->
    <dependency>
        <groupId>com.googlecode.htmlcompressor</groupId>
        <artifactId>htmlcompressor</artifactId>
        <version>1.5.2</version>
    </dependency>

    <!-- ApacheMQ HTTP jarfile set -->
    <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-client</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-http</artifactId>
    </dependency>
</dependencies>

知道如何解决这个问题吗?

【问题讨论】:

  • 这是完整的堆栈跟踪吗?
  • 我什至无法启动 Spring Boot,因此没有完整的堆栈跟踪。但原因很明显。 activemq-http 正在使用另一个版本的 jetty,它与默认的新 spring boot 2.2 嵌入式 jetty 冲突。
  • 你能发布你的 pom 吗?
  • 我做到了,我尝试排除 jetty-all。它有效,但我只是不喜欢这个解决方案。

标签: java spring-boot upgrade embedded-jetty


【解决方案1】:

ActiveMQ 在这里出错了。

jetty-all 不打算用作项目中的依赖项。

https://www.eclipse.org/lists/jetty-users/msg06030.html

它仅作为文档的命令行工具存在,用于向人们介绍 Jetty 的基本功能集。

它不包含,也不能包含所有的 Jetty。

Jetty 产生的所有东西的单一工件是不可能的。

正如@Shilan 指出的那样,排除jetty-all 是正确的解决方案。

使用其他适当的依赖项(似乎是spring-boot-starter-jetty)已经引入了您需要的正确的 Jetty 传递依赖项。

你可以在命令行中使用$ mvn dependency:tree来查看这个(排除jetty-all之前和之后)

您可能想要运行一个重复的类查找器 maven 插件,以查看您正在进行的其他重复类并更正这些类。

【讨论】:

  • 这不是我的错,它伴随着 activemq-http 依赖。但是我会从activemq jar中排除它。希望它能正常工作。
  • 我知道,这就是我提出问题的原因 - issues.apache.org/jira/browse/AMQ-7364
  • 所以只是为了把它记录在这里,这就是我排除码头的方式 org.apache.activemqactivemq-httporg.eclipse.jetty.aggregatejetty-all
猜你喜欢
  • 2018-02-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-08-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-12
相关资源
最近更新 更多