第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何在自定義過濾器中使用Java配置注入AuthenticationManager

如何在自定義過濾器中使用Java配置注入AuthenticationManager

慕后森 2019-10-16 14:48:49
我正在使用Spring Security 3.2和Spring 4.0.1我正在將xml配置轉(zhuǎn)換為Java配置。當(dāng)我在“過濾器”中添加注釋AuthenticationManager時(shí)@Autowired,出現(xiàn)異常Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.security.authentication.AuthenticationManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}我已經(jīng)嘗試了注入,AuthenticationManagerFactoryBean但是由于類似的異常也失敗了。這是我正在使用的XML配置<?xml version="1.0" encoding="UTF-8"?> <beans ...>    <security:authentication-manager id="authenticationManager">        <security:authentication-provider user-service-ref="userDao">            <security:password-encoder ref="passwordEncoder"/>        </security:authentication-provider>    </security:authentication-manager>    <security:http            realm="Protected API"            use-expressions="true"            auto-config="false"            create-session="stateless"            entry-point-ref="unauthorizedEntryPoint"            authentication-manager-ref="authenticationManager">        <security:access-denied-handler ref="accessDeniedHandler"/>        <security:custom-filter ref="tokenAuthenticationProcessingFilter" position="FORM_LOGIN_FILTER"/>        <security:custom-filter ref="tokenFilter" position="REMEMBER_ME_FILTER"/>        <security:intercept-url method="GET" pattern="/rest/news/**" access="hasRole('user')"/>        <security:intercept-url method="PUT" pattern="/rest/news/**" access="hasRole('admin')"/>        <security:intercept-url method="POST" pattern="/rest/news/**" access="hasRole('admin')"/>        <security:intercept-url method="DELETE" pattern="/rest/news/**" access="hasRole('admin')"/>    </security:http>
查看完整描述

2 回答

?
烙印99

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超13個(gè)贊

覆蓋方法authenticationManagerBean中WebSecurityConfigurerAdapter暴露出的AuthenticationManager使用內(nèi)建configure(AuthenticationManagerBuilder)作為一個(gè)Spring bean:


例如:


   @Bean(name = BeanIds.AUTHENTICATION_MANAGER)

   @Override

   public AuthenticationManager authenticationManagerBean() throws Exception {

       return super.authenticationManagerBean();

   }


查看完整回答
反對(duì) 回復(fù) 2019-10-16
?
holdtom

TA貢獻(xiàn)1805條經(jīng)驗(yàn) 獲得超10個(gè)贊

真正幫助我解決這個(gè)問題的是“名稱= BeanIds.AUTHENTICATION_MANAGER”。沒有它,它至少在我的環(huán)境中不起作用。

查看完整回答
反對(duì) 回復(fù) 2019-10-16
  • 2 回答
  • 0 關(guān)注
  • 2042 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)