我正在尝试访问应返回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
时,我得到了
有什么问题?