升级后启动服务器时出现Resteasy错误 “都映射到不允许的url模式[/ RESTEASY_HttpServlet30Dispatcher]”

问题描述

我将所有Resteasy依赖项更新为较新的版本,但是现在,在启动tomcat时,我总是遇到一个奇怪的错误。

这些是我的依赖项:

    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-jaxrs</artifactId>
        <version>3.13.0.Final</version>
    </dependency>
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-servlet-initializer</artifactId>
        <version>4.5.6.Final</version>
    </dependency>
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-multipart-provider</artifactId>
        <version>4.5.6.Final</version>
    </dependency>
    <dependency>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-cache-core</artifactId>
        <version>4.5.6.Final</version>
    </dependency>

这是我尝试启动服务器时遇到的错误:

    Caused by: java.lang.IllegalArgumentException: The servlets named [org.jboss.resteasy.plugins.server.servlet.HttpServlet30Dispatcher] and [org.jboss.resteasy.plugins.server.servlet.HttpServlet30Dispatcher] are both mapped to the url-pattern [/RESTEASY_HttpServlet30Dispatcher] which is not permitted
    at org.apache.tomcat.util.descriptor.web.WebXml.addServletMappingDecoded(WebXml.java:339)
    at org.apache.tomcat.util.descriptor.web.WebXml.merge(WebXml.java:1634)
    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1148)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:776)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:299)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5063)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    ... 43 more

我当时想这可能与依赖项中的冲突有关,但是我从maven中删除并再次下载,错误仍然存​​在。它工作正常...

谢谢!

解决方法

删除此依赖项:

<dependency>
   <groupId>org.jboss.resteasy</groupId>
   <artifactId>resteasy-jaxrs</artifactId>
   <version>3.13.0.Final</version>
</dependency>

RESTEasy 3中的resteasy-jaxrs和resteasy-client模块包含大多数框架类,在内部实现细节和供公众使用的细节之间没有真正的界限。在WildFly中,这些模块中的工件存档也包含在公共模块中。在RESTEasy 4.0.0中,人们普遍希望公共模块具有完全向后兼容的功能,以使项目的开发和维护更加容易。最后,这些大组件的拆分如下:

Resteasy文档: https://docs.jboss.org/resteasy/docs/4.5.6.Final/userguide/html/Migration_from_older_versions.html

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...