Jetty:run fails with NoSuchMethodError with Spring 5

雨燕双飞 提交于 2019-12-02 07:25:05

Spring 5 requires a Servlet 3.1 container as a bare minimum however as you are using Jetty 6.1 which is (at most) a Servlet 2.5 container. So that is obviously not going to work.

You will have to upgrade your Jetty version. To upgrade instead of the maven-jetty-plugin you will need to use the appropriate jetty-maven-plugin (the name has changed) and it is part of Eclipse now.

<maven-jetty-plugin.version>9.4.7.v20170914</maven-jetty-plugin.version>

<plugin>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <version>${maven-jetty-plugin.version}</version>
</plugin>

This should use the latest version of both the plugin and thus Jetty.

My bad I got it wrong. I think the problem is your jetty version:

https://mvnrepository.com/artifact/org.mortbay.jetty/jetty/6.1.26

Here the servlet API is 2.5 and when you add dependency in Maven and mark it with provided scope it means the required JARs will be provided on a later stage and not packed with the war. So the code compiles properly in the IDE and development but when you try to run it with jetty it uses the actual servlet-api coming from the jetty version. And for that method you need servlet-api version 3 or above

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!