2012-12-28 3 views
10
私の春のアプリケーションで

Possible Duplicate:
Getting error org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named ‘springSecurityFilterChain’ is definedauthenticationManager

という名前のBeanが、私はこのエラーを取得しておくん:

No bean named 'org.springframework.security.authenticationManager' is defined: Did you forget to add a gobal <authentication-manager> element to your configuration (with child <authentication-provider> elements)? Alternatively you can use the authentication-manager-ref attribute on your <http> and <global-method-security> elements. 

私の春のセキュリティコンテキストxmlファイルでは、私は次のように定義されています

<beans:bean id="myUserDetailsService" class="com.myProject.core.security.MyUserDetailsService" /> 

<beans:bean id="encoder" class="com.myProject.core.security.HmacPasswordEncoder" /> 

<authentication-manager id="clientAuthenticationManager" > 
    <authentication-provider user-service-ref="myUserDetailsService"> 
     <password-encoder ref="encoder" /> 
    </authentication-provider> 
</authentication-manager> 

認証マネージャーと認証プロバイダーを明確に定義した場合、その不平を言う理由は何ですか?

注:これは役立つかもしれない、そのもっと説明エラー:このリンクで

org.springframework.beans.factory.BeanCreationException: Error creating bean with 
name 'org.springframework.security.filterChains': Cannot resolve reference to bean 
'org.springframework.security.web.DefaultSecurityFilterChain#2' while setting bean 
property 'sourceList' with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#2': 
Cannot resolve reference to bean 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' 
while setting constructor argument with key [1]; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error creating bean with 
name 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0': 
Cannot resolve reference to bean 'org.springframework.security.authentication.ProviderManager#0' 
while setting bean property 'authenticationManager'; nested exception is 
org.springframework.beans.factory.BeanCreationException: Error creating bean with 
name 'org.springframework.security.authentication.ProviderManager#0': Cannot resolve 
reference to bean 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0' 
while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0': 
FactoryBean threw exception on object creation; nested exception is 
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 
'org.springframework.security.authenticationManager' is defined: Did you forget to 
add a gobal <authentication-manager> element to your configuration (with child 
<authentication-provider> elements)? Alternatively you can use the authentication-manager-ref 
attribute on your <http> and <global-method-security> elements. 

答えて

13

authenticationManagerはによって参照されます名前を変更してください。

<authentication-manager alias="authenticationManager"> 
    <authentication-provider user-service-ref="myUserDetailsService"> 
     <password-encoder ref="encoder" /> 
    </authentication-provider> 
</authentication-manager> 
+0

これは私にとってはうまくいきませんでした。 – user1007895

+0

あるいは<認証マネージャ> <認証プロバイダのユーザサービス-REF = "myUserDetailsS​​ervice"> <パスワードエンコーダREF = "エンコーダ" /> iMysak

+0

2番目の提案から 'id =" clientAuthenticationManager "'を削除し、それが動作するかどうかを確認してください - 更新された編集を参照してください。 –

1

ルック:

Notice that the filter is actually a DelegatingFilterProxy, and not the class that will actually implement the logic of the filter. What DelegatingFilterProxy does is delegate the Filter's methods through to a bean which is obtained from the Spring application context.

...

You need to define a bean named springSecurityFilterChain that implements javax.servlet.Filter in your application context.

+0

いくつかのコードを表示できますか? – user1007895

2

あなたは、Spring Security Contextファイルを変更してclientAuthenticationManagerを探す必要があります。この行をhttpの設定に追加できます

<http use-expressions="true" authentication-manager-ref="clientAuthenticationManger"> 
+0

はい、「authenticationManager」という名前で認証マネージャーの参照を取得しようとしています。そのため、認証マネージャーrefを記入してください。 –

関連する問題