새소식

Framework/🍃 Spring

[Solved] Can't configure antMatchers after anyRequest

  • -
728x90

🔥 Problem

👉 nested exception is java.lang.IllegalStateException: Can't configure antMatchers after anyRequest

🧙 Solution

👉 .anyRequest().authenticated() to be used only once!

Please check if you used them once.

    http
        .httpBasic()
            .and()
        .authorizeRequests()
            .antMatchers("/test/**").permitAll()
            .and()
        .authorizeRequests()
            .antMatchers("/admin/**").hasAnyRole("ADMIN")
            .anyRequest().authenticated()
            .and()
        .formLogin()
            .permitAll();

 

👉 If that doesn't solve the problem??

Remove the .anyRequest() and .authenticated().

Then this problem will be solved.

 

Did my writing help you?

Please press the Thumb Up button
If you have any questions, please leave them in the comments

💯포스트 후원하기

 

 

 

 

 

 

반응형
Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.