弹簧启动:文件系统故障 - 配置
问题描述:
不幸的是,我斯塔克。 情况:我的应用程序运行良好,但是当我装它与Spring-开机安全性,所有的CSS,JS,IMG文件夹变得不可访问....弹簧启动:文件系统故障 - 配置
我试图采用MVCConfig性质在我的application.properties文件中,但它没有工作。 :( (spring.mvc.static路径模式= /资源/ **)
答
你必须创建一个WebSecurityConfigurerAdapter
类设置的安全设置。请注意,你需要如下指定未受保护的URL。
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/", "/assets/**", "/favicon.ico").permitAll()
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.permitAll()
.and()
.logout()
.permitAll();
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.withUser("user").password("password").roles("USER");
}
}
谢谢,它为我工作!:) – lombocska