Skip to content
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

Allow multiple @Import statements for migration from xml [SPR-17165] #21701

Open
spring-issuemaster opened this issue Aug 10, 2018 · 0 comments
Open

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Aug 10, 2018

Jeff opened SPR-17165 and commented

In migrating from xml defined configuration java defined configuration, it is not possible to load xml and .class configurations in arbitrary orders. This makes mixing the two somewhat impossible and forces us to stay with the xml configurations. In our case, our xml configs are huge, and migrating them all at once isn't desired.

For example:

The below is the desired configuration. The PropertiesConfig is loaded first, as it loads all property placeholders for use in all of the xml files.

At the end, I'd like to add a MongoConfig.class to add more mongo-spring-data defined beans within the application that reference the beans defined in applicationContext-mongo.xml.

Unfortunately, I can't order the loading of configuration classes between xml and .class files - I have to either load all class files first then all xml files, or load all xml files first, then all class files.

The implementation below gives me the error: "Duplicate annotation of non-repeatable type @Import"

@Configuration
@Import({PropertiesConfig.class})
@ImportResource({
"classpath:META-INF/spring/applicationContext-assets.xml",
"classpath:META-INF/spring/applicationContext-mongo.xml",
"classpath:META-INF/spring/applicationContext-security.xml",
"classpath:META-INF/spring/applicationContext.xml"})
@Import({MongoConfig.class})
public class CoreConfig {

    // more config here.

}

 

Please allow spring to have ordered loading of configuration files wheather they are xml or .class configurations by making the Import annotations repeatable, or provide another solution.


No further details from SPR-17165

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.