2016-04-15 9 views
1

正確なtutorialに続いて、セキュアなスプリング・ブート・アプリケーションを構築しています。AlreadyBuiltExceptionスプリング・セキュリティーを持つSpringブート・アプリケーションを実行中

これは私のセキュリティの設定クラスである:私は@ConfigurationAuthenticationConfiguration前にクラスをコメントアウトした場合

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 
@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");    
     } 
    } 

} 

はしかし、私は次のエラーを得ましたこのエラーは消えてしまいます。しかし、@Configuration注釈が削除された場合、LDAP認証が設定されているとは思われません。

なぜオブジェクトが既に作成されているとしますか?それは何の「対象」ですか?以下は、あなたがApacheDSの2.0を使用しようとしている私のpom.xml

<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> 
+0

'@ Autowired'を' init'メソッドに追加します。 –

+0

@AliDehghaniは、それと同じエラーを試しました。 – ddd

+0

'pom.xml'または' build.gradle'を追加してください.. –

答えて

1

で依存関係ですが、春のセキュリティは唯一の原因2.0で破りAPIの変更や、より最近の1.5.xのリリースに1.5.5をサポートしています。 1.5.5を使用するようにPOMを更新すると問題が解決されます。

関連する問題