-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Bean Definition Issue - Using XML Files #710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It sounds like the workaround is to add a Can you provide a simple project or test case that shows the problem? |
Yes, that works around the issue for now, however the point of having these in separate XML files is because each XML file represented a module in the application which had it's own @componentscan directive. I'll work on an example to show the issue. |
Uploaded example to https://github.com/lstanden/springboot710 This is probably more complicated than it needed to be for the issue, but it shows the specific use case that I've got, and why there's separate component-scan directives. If you deploy the resulting .war to a Jetty server, it runs just fine. Starting the same application through Spring Boot and using the @ImportResource annotation causes a NoSuchBeanDefinitionException. |
The test is actually for a variant of SPR-11430 raised as an issue in Spring Boot: spring-projects/spring-boot#710. In this form there is an @ImportResource() where the XML contains a @configuration that is not processed. It seems even more surprising to users than the vanilla SPR-11430 problem because (as the test shows) the @configuration *is* processed if it is not imported via @ImportResource (e.g. if the XML is loaded directly).
I don't think this is anything to do with Boot; probably a facet of this: https://jira.spring.io/browse/SPR-11430, https://jira.spring.io/browse/SPR-11723. Irritating, I agree, but we probably need to chase it in the Spring JIRA to get it to behave the way you expect. |
Thanks Dave, much appreciated... I'll follow the progress in the Spring JIRA. |
Ran into an issue today when trying to convert a working Spring 4 application across to use Spring Boot.
For several reasons, we've gone with XML configuration, and I was looking to use Spring Boot to produce an executable WAR artifact for deployment. We currently use hand rolled POM to do this. We might convert to JavaConfig at a later date, but we're stuck with XML for now.
I have a multi-module maven project, and each project has it's own XML file with a specific context:component-scan entry. In the startup logs, I can see these files being processed without error, however the component-scan doesn't seem to run, or it runs too late. I get bean not defined errors.
If I put a single @componentscan in the Starter class (i.e. in JavaConfig), then the application loads fine.
Is there a workaround for this, or is it a limitation that context:component-scan directives in XML are not processed?
The text was updated successfully, but these errors were encountered: