fengbin2005 发表于 2013-2-1 12:11:56

关于当候选 Bean 数目不为 1 时的应对方法

正确配置:
spring配置
A.配置命名空间
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
             http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
            http://www.springframework.org/schema/tx
            http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
            http://www.springframework.org/schema/aop
            http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
         http://www.springframework.org/schema/context
         http://www.springframework.org/schema/context/spring-context-2.5.xsd">

B.加入自动注入
<context:annotation-config/>
   <context:component-scan base-package="net.shopxx"/>

C.spring组件
@Component("jcaptchaFilter")
public class JcaptchaFilter implements Filter {

D.引入需要注入的类
public class AdminAction extends ActionSupport{
   
@Autowired
@Qualifier("jcaptchaFilter")
private JcaptchaFilter jcaptchaFilter;
页: [1]
查看完整版本: 关于当候选 Bean 数目不为 1 时的应对方法