简体   繁体   中英

How to make my annotations beans available to XML configuration file

I am moving some beans definition from a XML to a @Configuration class, but there is one dependency that it will remain in the XML that requires one of those being moved. I read that @Configuration beans are loaded on the Context first than XML.

But I keep on getting this Exception.

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'entityEventManagerImpl': Unsatisfied dependency expressed through field 'jmsTopicTemplate'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.jms.core.JmsTemplate' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value="jmsTopicTemplate")}

The @Configuration bean are being loaded after the XML bean.

Anything that I am missing to make the @Configuration load first???

I tried doing @ComponentScan but it did not work.

You can use the @ImportResource annotation for this purpose, but generally you should keep the XML you are importing to a minimum, so you probably want to move the dependent beans to a separate file.

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