spring boot请求端点返回404

时间:2015-10-05 20:43:09

标签: java spring maven spring-mvc spring-boot

我使用spring-boot和maven构建一个新的java项目,但我无法访问我的端点。

当我启动tomcat时,这是控制台的一部分,我可以看到所有的所有端点:

DEBUG [localhost-startStop-1] security.OAuth2ServerConfiguration: AuthorizationServerConfigurationorg.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer@f8f122
INFO  [localhost-startStop-1] mvc.EndpointHandlerMapping: Mapped "{[/metrics/{name:.*}],methods=[GET]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.MetricsMvcEndpoint.value(java.lang.String)
INFO  [localhost-startStop-1] mvc.EndpointHandlerMapping: Mapped "{[/metrics],methods=[GET]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
INFO  [localhost-startStop-1] mvc.EndpointHandlerMapping: Mapped "{[/beans],methods=[GET]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
INFO  [localhost-startStop-1] mvc.EndpointHandlerMapping: Mapped "{[/mappings],methods=[GET]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
INFO  [localhost-startStop-1] mvc.EndpointHandlerMapping: Mapped "{[/autoconfig],methods=[GET]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
INFO  [localhost-startStop-1] mvc.EndpointHandlerMapping: Mapped "{[/info],methods=[GET]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
INFO  [localhost-startStop-1] mvc.EndpointHandlerMapping: Mapped "{[/dump],methods=[GET]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
INFO  [localhost-startStop-1] mvc.EndpointHandlerMapping: Mapped "{[/health]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.invoke(java.security.Principal)
INFO  [localhost-startStop-1] mvc.EndpointHandlerMapping: Mapped "{[/trace],methods=[GET]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
INFO  [localhost-startStop-1] mvc.EndpointHandlerMapping: Mapped "{[/configprops],methods=[GET]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
INFO  [localhost-startStop-1] mvc.EndpointHandlerMapping: Mapped "{[/env/{name:.*}],methods=[GET]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EnvironmentMvcEndpoint.value(java.lang.String)
INFO  [localhost-startStop-1] mvc.EndpointHandlerMapping: Mapped "{[/env],methods=[GET]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.EndpointMvcAdapter.invoke()
INFO  [localhost-startStop-1] endpoint.FrameworkEndpointHandlerMapping: Mapped "{[/oauth/authorize],methods=[POST],params=[user_oauth_approval]}" onto public org.springframework.web.servlet.View org.springframework.security.oauth2.provider.endpoint.AuthorizationEndpoint.approveOrDeny(java.util.Map<java.lang.String, java.lang.String>,java.util.Map<java.lang.String, ?>,org.springframework.web.bind.support.SessionStatus,java.security.Principal)
INFO  [localhost-startStop-1] endpoint.FrameworkEndpointHandlerMapping: Mapped "{[/oauth/authorize]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.security.oauth2.provider.endpoint.AuthorizationEndpoint.authorize(java.util.Map<java.lang.String, java.lang.Object>,java.util.Map<java.lang.String, java.lang.String>,org.springframework.web.bind.support.SessionStatus,java.security.Principal)
INFO  [localhost-startStop-1] endpoint.FrameworkEndpointHandlerMapping: Mapped "{[/oauth/token],methods=[GET]}" onto public org.springframework.http.ResponseEntity<org.springframework.security.oauth2.common.OAuth2AccessToken> org.springframework.security.oauth2.provider.endpoint.TokenEndpoint.getAccessToken(java.security.Principal,java.util.Map<java.lang.String, java.lang.String>) throws org.springframework.web.HttpRequestMethodNotSupportedException
INFO  [localhost-startStop-1] endpoint.FrameworkEndpointHandlerMapping: Mapped "{[/oauth/token],methods=[POST]}" onto public org.springframework.http.ResponseEntity<org.springframework.security.oauth2.common.OAuth2AccessToken> org.springframework.security.oauth2.provider.endpoint.TokenEndpoint.postAccessToken(java.security.Principal,java.util.Map<java.lang.String, java.lang.String>) throws org.springframework.web.HttpRequestMethodNotSupportedException
INFO  [localhost-startStop-1] endpoint.FrameworkEndpointHandlerMapping: Mapped "{[/oauth/check_token]}" onto public java.util.Map<java.lang.String, ?> org.springframework.security.oauth2.provider.endpoint.CheckTokenEndpoint.checkToken(java.lang.String)
INFO  [localhost-startStop-1] endpoint.FrameworkEndpointHandlerMapping: Mapped "{[/oauth/confirm_access]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.security.oauth2.provider.endpoint.WhitelabelApprovalEndpoint.getAccessConfirmation(java.util.Map<java.lang.String, java.lang.Object>,javax.servlet.http.HttpServletRequest) throws java.lang.Exception
INFO  [localhost-startStop-1] endpoint.FrameworkEndpointHandlerMapping: Mapped "{[/oauth/error]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.security.oauth2.provider.endpoint.WhitelabelErrorEndpoint.handleError(javax.servlet.http.HttpServletRequest)

当我发送q请求时,例如:

curl -v http://localhost:8080/env

我收到404错误的

 Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /env HTTP/1.1
> User-Agent: curl/7.35.0
> Host: localhost:8080
> Accept: */*
> 
< HTTP/1.1 404 Not Found
* Server Apache-Coyote/1.1 is not blacklisted
< Server: Apache-Coyote/1.1
< Content-Type: text/html;charset=utf-8
< Content-Language: en
< Content-Length: 1006
< Date: Mon, 05 Oct 2015 20:27:45 GMT
< 
* Connection #0 to host localhost left intact
<!DOCTYPE html><html><head><title>Apache Tomcat/8.0.20 - Error

我应该如何访问我的终端?我对所有端点都有同样的问题:oauth / token,health,metrics,....

如果有人想查看所有项目,请查看以下问题: https://stackoverflow.com/questions/32812830/spring-boot-oauth2-authentification-error

感谢您的帮助

0 个答案:

没有答案