【发布时间】:2017-12-19 23:39:44
【问题描述】:
我有一个可以与 oauth2(作为资源服务器)一起正常工作的 Spring Boot 应用程序。没有自定义 configure(HttpSecurity http) 方法。只有
spring-boot-starter-security
spring-security-oauth2
spring-security-jwt
被添加到 pom 中。
现在我想添加应该不受保护的端点。所以(在许多 SO 响应之后)我开始添加:
@Configuration
public class Security extends ResourceServerConfigurerAdapter {
@Override
public void configure(HttpSecurity http) throws Exception {
}
}
然后我得到了:
无法将 org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer@6513fd22 应用于已构建的对象
完全错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is java.lang.IllegalStateException: Cannot apply org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer@6513fd22 to already built object
那么我应该如何配置我的安全性以添加匿名访问端点?
【问题讨论】:
标签: java spring spring-boot spring-security spring-security-oauth2