Punter Vicky
Punter Vicky

Reputation: 16992

spring boot - component scan beans defined in spring.xml

I am developing an application using spring boot.I have added some legacy dependency libraries that have xml configuration. I would like to use the beans defined in spring.xml file. I have added the package in my component scan , however the bean doesn't seem to be picked up. Should I add any additional configuration for spring boot to read xml configuration?

Upvotes: 2

Views: 1924

Answers (1)

Sundararaj Govindasamy
Sundararaj Govindasamy

Reputation: 8495

You need to import beans from xml (one application context) to annotation/java config (another application context) like below.

@ImportResource("classpath:spring.xml")

Add this into your main class of your spring boot application.

Now, all the beans defined in your legacy spring.xml will be available in this Spring Boot application's Application Context.

Upvotes: 2

Related Questions