Я пытаюсь настроить Spring Security и получить следующую ошибку: < /p>
вызван: java.lang.illegalstateexception: не удается настроить Antmatchers после AnmeRequest < /p>
< /blockquote>
Это My SecurityConfig: Pr>
wearquest. />
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfig extends WebSecurityConfigurerAdapter{
@Autowired
private UserDetailsService userDetailsService;
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService).passwordEncoder(encodePWD());
}
@Override
protected void configure(HttpSecurity http) throws Exception{
http
.csrf().disable();
http
.httpBasic()
.and()
.authorizeRequests()
.antMatchers("/rest/**").permitAll()
.anyRequest().authenticated()
.and()
.authorizeRequests()
.antMatchers("/secure/**").hasAnyRole("ADMIN")
.anyRequest().authenticated()
.and()
.formLogin()
.permitAll();
http
.authorizeRequests()
.antMatchers("/login").permitAll();
}
@Bean
public BCryptPasswordEncoder encodePWD(){
return new BCryptPasswordEncoder();
}
}
< /code>
Я уже пробовал позвонить httpsecurityauthorizeRequests (). anyRequest (). Authenticated () < /code> Как упомянуто здесь,
все еще не работал
... любое предложение было бы полезным. < /p>
Подробнее здесь: https://stackoverflow.com/questions/601 ... antmatcher
Не могу настроить Antmatchers после AnyRequest (множества Antmatcher) ⇐ JAVA
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Заполнить 52-канальный массив имен карт из множества костюмов и множества рядов
Anonymous » » в форуме Php - 0 Ответы
- 31 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Метод antMatchers() не определен для типа AuthorizeHttpRequestsConfigurer
.AuthorizedUrl
Anonymous » » в форуме JAVA - 0 Ответы
- 27 Просмотры
-
Последнее сообщение Anonymous
-