[英]Spring - update java classes base on XML bean definition
We are using Spring 3, all of our bean declarations and property mappings are done through XML. 我们正在使用Spring 3,我们所有的bean声明和属性映射都是通过XML完成的。 I've been tasked to update the java classes to use the @Resource
where needed. 我的任务是更新Java类以在需要的地方使用@Resource
。 We have a lot of classes. 我们有很多课程。
We use Eclipse for the IDE. 我们将Eclipse用于IDE。
I've never written a script to update Java code, so thought I'd ask for some suggestion on how to approach the problem. 我从未编写过用于更新Java代码的脚本,因此想为我提供一些有关如何解决该问题的建议。
Thanks! 谢谢!
I had a similar issue converting legacy EJB @Stateless
services to Spring beans - hundreds of them and I didn't want to change all just to add @Bean
or @Service
annotations. 我有一个类似的问题,将旧版EJB @Stateless
服务转换为Spring @Bean
数百个它们,我不想全部更改,仅添加@Bean
或@Service
批注。
I found the component-scan util to be most useful: 我发现component-scan util最有用:
<context:component-scan base-package="com.example.businessservices">
<context:include-filter type="annotation" expression="javax.ejb.Stateless"/>
</context:component-scan>
See what other options of available for the filter type and expressions, and use one that matches your criteria to identifying your classes that need to be beans. 查看可用于过滤器类型和表达式的其他选项,并使用与您的条件匹配的选项来识别需要为bean的类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.