2017-03-03 5 views
0

残念ながら、私は固執しました。 状況:私のアプリは良い実行されますが、私は....春ブーツ・セキュリティ、アクセス不能になってすべてのCSS、JS、IMGフォルダにSpring-Boot:ファイルシステムの障害 - 設定

My file structure

それを装着したとき、私はMVCConfigプロパティを採用しようとしました私のapplication.propertiesファイルでは動作しませんでした。 :( (spring.mvc.staticパスパターン= /リソース/ **)

答えて

1

あなたはセキュリティ設定を設定する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"); 
    } 
} 
+0

ありがとう、それは私のために働いた!:) – lombocska