我想将xml bean创建转换为注释。我已经转换了一些,但我对这个有问题:
<bean id="anyClass" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="target">
<bean class="pl.spring.demo.class.impl.AnyClassImpl">
<property name="anyName" ref="anyName" />
</bean>
</property>
<property name="interceptorNames">
<list>
<value>anyValue</value>
</list>
</property>
</bean>
答案 0 :(得分:2)
如果您想尝试使用Spring Java Beans,可以试试这样:
@Configuration
public class ProxyFactoryBeanConfiguration{
@Autowired
private pl.spring.demo.class.impl.AnyClassImpl anyClassImpl;
@Autowired
private List<String> interceptorNames;
@Bean
public org.springframework.aop.framework.ProxyFactoryBean anyClass(){
ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
proxyFactoryBean.setTarget(anyClassImpl);
proxyFactoryBean.setInterceptorNames(interceptorNames);
return proxyFactoryBean;
}
}
确保使用所需的依赖项注入anyClassImpl。