0

我需要在我从配置属性中读取的条件下加载特定的 bean。我有两个豆子,所以我想按如下方式加载它

public interface MediatorInt {

public void init();

}

class A implements MediatorInt {
        init() { It does some task }
    }

class B implements MediatorInt {
    init(){ It does some task }
}

public class MasterNewGenImpl {
    @Autowired
    @Qualifier("config")
    private Configuration config;

    @Autowired
    MediatorInt mediatorInt;

    private final Logger logger = Logger.getLogger(getClass());

    public void startService() {
        mediatorInt.init();
    }
}

<context:component-scan base-package="com.ca"/>
    <bean id="config" class="com.ca.configuration.ConfigImplementation"/>    
    <bean id="masterSlave" class="com.ca.masterslave.A"/>
    <bean id="systemState" class="com.ca.masterslave.B"/>
    <bean id="masterSlaveNewGen" class="com.ca.masterslave.MasterNewGenImpl">
    <property name = "mediatorInt" value="#{config.getMediatorMode() == 'true' ? 'systemState' : 'masterSlave'}" />
</bean> 

但是 bean 没有被加载。

如果语法或使用方法有任何错误,请您帮忙。

4

0 回答 0