在我的Spring Boot应用程序中,我试图使用基本的Spring Security来实现登录。
public Response verifyLogin( String username, String password ) throws Exception
{
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
HttpEntity<Login> requestEntity = new HttpEntity<>( new Login( username, password ), headers );
ResponseEntity<Response<UserDetail>> response = restTemplate.exchange( getEndpoint( ConfigurationConstants.LOGIN_URL ), HttpMethod.POST, requestEntity, new ParameterizedTypeReference<Response<UserDetail>>()
{
} );
return response.getBody();
}
restTemplate.exchange 方法上方引发以下异常。
org.springframework.web.client.HttpClientErrorException: 404 Not Found
at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:78) ~[spring-web-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:700) ~[spring-web-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:653) ~[spring-web-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:613) ~[spring-web-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:559) ~[spring-web-4.3.12.RELEASE.jar:4.3.12.RELEASE]
at it.codegen.tbx.pbs.web.service.LoginService.verifyLogin(LoginService.java:60) ~[classes/:na]
任何建议都值得赞赏。
谢谢。