Не могу настроить Antmatchers после AnyRequest (множества Antmatcher)JAVA

Программисты JAVA общаются здесь
Anonymous
Не могу настроить Antmatchers после AnyRequest (множества Antmatcher)

Сообщение Anonymous »

Я пытаюсь настроить 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

Вернуться в «JAVA»