笑故挽风 2016-06-16 23:06 采纳率: 100%
浏览 168

Spring Boot出现Jetty错误

I have an web application using Spring Boot and a jetty server. I am making calls through ajax but instead of them getting mapped to my Spring Controller they are resulting in an error.

The error:

2016-06-16 18:55:25.450  WARN 11772 --- [tp1170788511-19] o.eclipse.jetty.servlet.ServletHandler   : Error for /test
java.lang.NoClassDefFoundError: org/eclipse/jetty/http/HttpMethod

and:

2016-06-16 18:55:25.451  WARN 11772 --- [tp1170788511-19] o.e.jetty.server.AbstractHttpConnection  : /test
java.lang.NoClassDefFoundError: org/eclipse/jetty/http/HttpMethod

The Ajax:

 $.ajax({
    url: "/test",
    type: "POST",
    async: false,,
    success: function (response) {
    ...
    }

The Controller:

@Controller
public class LoginController {

@RequestMapping(value="/test", method=RequestMethod.POST)
public String countingForm(Model model) {
    System.out.println("test");
    return "test";
}

}

If anyone could shine some light on whats going wrong that would be greatly appreciated.

  • 写回答

1条回答 默认 最新

  • weixin_33744854 2016-06-16 23:15
    关注

    Did you excluded tomcat from spring-boot-starter-web?

        <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>
    
    评论

报告相同问题?