简体   繁体   中英

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. I've been tasked to update the java classes to use the @Resource where needed. We have a lot of classes.

We use Eclipse for the 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.

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.

I found the component-scan util to be most useful:

<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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM