问题描述
<authentication-manageralias="authenticationManager"><authentication-provideruser-service-ref="MyUserDetailService"><password-encoderref="myPasswordEncode"><salt-sourceuser-property="username"/></password-encoder></authentication-provider></authentication-manager><!--指定自己的密码验证类--><beans:beanid="myPasswordEncode"class="org.springmvc.security.MyPasswordEncode"><beans:constructor-argname="encode"value="md5"></beans:constructor-arg></beans:bean>
这是在自己的security.xml中配置的自定义加密方法,但是在项目启动的时候就报错了,在网上找了很长时间,但是一直没有找到解决方法,求大家帮帮忙。启动报错为:Causedby:org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'org.springframework.security.web.DefaultSecurityFilterChain#0':Cannotresolvereferencetobean'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0'whilesettingconstructorargumentwithkey[2];nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0':Cannotresolvereferencetobean'org.springframework.security.authentication.ProviderManager#0'whilesettingbeanproperty'authenticationManager';nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'org.springframework.security.authentication.ProviderManager#0':Cannotresolvereferencetobean'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0'whilesettingconstructorargument;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'org.springframework.security.config.authentication.AuthenticationManagerFactoryBean#0':FactoryBeanthrewexceptiononobjectcreation;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'org.springframework.security.authenticationManager':Cannotresolvereferencetobean'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0'whilesettingconstructorargumentwithkey[0];nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname'org.springframework.security.authentication.dao.DaoAuthenticationProvider#0':Cannotresolvereferencetobean'myPasswordEncode'whilesettingbeanproperty'passwordEncoder';nestedexceptionisorg.springframework.beans.factory.UnsatisfiedDependencyException:Errorcreatingbeanwithname'myPasswordEncode'definedinfile[F:tomcat7webappsnewCRMWEB-INFclassesspring-security.xml]:Unsatisfieddependencyexpressedthroughconstructorargumentwithindex0oftype[java.lang.String]:Ambiguousconstructorargumenttypes-didyouspecifythecorrectbeanreferencesasconstructorarguments?