Spring boot 1.5.7
Получаю вот такую картину:
@Configuration
@EnableWebMvc
public class MvcConfiguration extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry
.addResourceHandler("/resources/**")
.addResourceLocations("/resources/");
}
}
@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.
authorizeRequests()
.antMatchers("/").hasAnyRole("USER", "ADMIN")
.antMatchers("/welcome").hasAnyRole("USER", "ADMIN")
.antMatchers("/admin").hasRole("ADMIN")
.and()
.formLogin().loginPage("/login").defaultSuccessUrl("/welcome").failureUrl("/login?error")
.usernameParameter("username").passwordParameter("password")
.and().logout()
.logoutSuccessUrl("/login?logout");
}
Вот что творится в логах:
2017-11-20 03:22:36.740 WARN 11224 --- [nio-8080-exec-9] o.s.web.servlet.PageNotFound : No mapping found for HTTP request with URI [/img/logo.png] in DispatcherServlet with name 'dispatcherServlet'
2017-11-20 03:22:36.740 DEBUG 11224 --- [nio-8080-exec-9] o.s.b.a.e.mvc.EndpointHandlerMapping : Looking up handler method for path /error
2017-11-20 03:22:36.741 DEBUG 11224 --- [nio-8080-exec-9] o.s.b.a.e.mvc.EndpointHandlerMapping : Did not find handler method for [/error]
2017-11-20 03:22:37.180 DEBUG 11224 --- [nio-8080-exec-4] o.s.b.a.e.mvc.EndpointHandlerMapping : Looking up handler method for path /js/jquery.min.js
2017-11-20 03:22:37.182 DEBUG 11224 --- [nio-8080-exec-4] o.s.b.a.e.mvc.EndpointHandlerMapping : Did not find handler method for [/js/jquery.min.js]
2017-11-20 03:22:37.182 WARN 11224 --- [nio-8080-exec-4] o.s.web.servlet.PageNotFound : No mapping found for HTTP request with URI [/js/jquery.min.js] in DispatcherServlet with name 'dispatcherServlet'
2017-11-20 03:22:37.183 DEBUG 11224 --- [nio-8080-exec-4] o.s.b.a.e.mvc.EndpointHandlerMapping : Looking up handler method for path /error
2017-11-20 03:22:37.184 DEBUG 11224 --- [nio-8080-exec-4] o.s.b.a.e.mvc.EndpointHandlerMapping : Did not find handler method for [/error]
2017-11-20 03:22:37.274 DEBUG 11224 --- [io-8080-exec-10] o.s.b.a.e.mvc.EndpointHandlerMapping : Looking up handler method for path /js/login.js
2017-11-20 03:22:37.276 DEBUG 11224 --- [io-8080-exec-10] o.s.b.a.e.mvc.EndpointHandlerMapping : Did not find handler method for [/js/login.js]
2017-11-20 03:22:37.277 WARN 11224 --- [io-8080-exec-10] o.s.web.servlet.PageNotFound : No mapping found for HTTP request with URI [/js/login.js] in DispatcherServlet with name 'dispatcherServlet'
Ресурсы подключаю так:
<head>
<title>Auth page</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" th:href="@{/css/bootstrap.min.css}" type="text/css" />
<link rel="stylesheet" th:href="@{/css/bootstrap-grid.min.css}" type="text/css" />
<link rel="stylesheet" th:href="@{/css/bootstrap-reboot.min.css}" type="text/css" />
<link rel="stylesheet" th:href="@{/css/main.css}" type="text/css" />
<link rel="stylesheet" th:href="@{/css/font-awesome.min.css}" type="text/css" />
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,800' rel='stylesheet' type='text/css'/>
</head>