Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-17165

Allow multiple @Import statements for migration from xml

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 5.x Backlog
    • Component/s: Core
    • Labels:
    • Last commented by a User:
      true

      Description

      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.

        Attachments

          Activity

            People

            • Assignee:
              juergen.hoeller Juergen Hoeller
              Reporter:
              jspringcoder Jeff
              Last updater:
              Spring Issuemaster
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Days since last comment:
                47 weeks, 5 days ago