我尝试访问Spring Boot应用程序中的URL时找不到页面

时间:2017-05-10 14:24:27

标签: java spring gradle spring-boot jetty

我正在尝试访问应返回localhost:8080/tree-model-app/ping的{​​{1}}网址。但我得到true该网址。

以下是404申请<{1}}的{​​{1}}

main

这是我的Spring Boot

@SpringBootApplication
public class TreeModelApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run(TreeModelApplication.class, args);
    }

    @Bean
    public ServletRegistrationBean servletRegistrationBean() throws Exception {
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(new RootServlet(), "/tree-model-app");
        registrationBean.setLoadOnStartup(1);
        registrationBean.setAsyncSupported(true);
        return registrationBean;
    }
}

这是我的servlet

public class RootServlet extends ServletHttpHandlerAdapter {
    public RootServlet(HttpHandler httpHandler) {
        super(httpHandler);
    }

    public RootServlet() {
        this(WebHttpHandlerBuilder
                .webHandler(toHttpHandler(routingFunction()))
                .build()
        );
    }

    private static RouterFunction<?> routingFunction() {
        return route(GET("/ping"), new PingHandlerFunction());
    }

}

这是我的handler

public class PingHandlerFunction implements HandlerFunction<ServerResponse> {
    @Override
    public Mono<ServerResponse> handle(ServerRequest request) {
        return ok().body(fromObject("true"));
    }
}

但是当我尝试访问build.gradle时,我得到了

enter image description here

有什么问题?

0 个答案:

没有答案