首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >具有Spring安全性的AlreadyBuiltException运行spring应用程序

具有Spring安全性的AlreadyBuiltException运行spring应用程序
EN

Stack Overflow用户
提问于 2016-04-15 19:41:53
回答 1查看 265关注 0票数 1

我正在按照确切的教程构建安全的Spring应用程序。

这是我的安全配置类:

代码语言:javascript
复制
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .authorizeRequests()
                .anyRequest().fullyAuthenticated()
                .and()
            .formLogin();
    }

    @Configuration
    protected static class AuthenticationConfiguration extends
            GlobalAuthenticationConfigurerAdapter {

        @Override
        public void init(AuthenticationManagerBuilder auth) throws Exception {
            auth
                .ldapAuthentication()
                    .userDnPatterns("uid={0},ou=people")
                    .groupSearchBase("ou=groups")
                    .contextSource().ldif("classpath:test-server.ldif");            
        }
    }   

}

但是,当我在Spring中运行应用程序时,我得到了以下错误:

代码语言:javascript
复制
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain'
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]
Caused by: org.springframework.security.config.annotation.AlreadyBuiltException: This object has already been built

如果我在@Configuration类def之前注释掉AuthenticationConfiguration,这个错误就会消失。但是,我认为如果删除了@Configuration注释,就不会配置ldap。

为什么它说这个物体已经建好了?它指的是什么“对象”?下面是我的pom.xml中的依赖项

代码语言:javascript
复制
  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-tomcat</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-jpa</artifactId>
      </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-ldap</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.directory.server</groupId>
        <artifactId>apacheds-all</artifactId>
        <version>2.0.0-M20</version>
    </dependency>
    <dependency>
      <groupId>com.oracle</groupId>
      <artifactId>ojdbc7</artifactId>
      <version>12.1.0.1</version>
    </dependency>
  </dependencies>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-09-13 15:30:27

您正在尝试使用ApacheDS 2.0,但是Security只支持1.5.5,这是因为在2.0和最近的1.5.x版本中破坏了API2.0的更改。更新pom以使用1.5.5应该可以解决这个问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36655606

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档