1. 程式人生 > >Spring boot 梳理 - Configuration Class

Spring boot 梳理 - Configuration Class

  1. 推薦使用 Java-based configuration ,也可以使用xml
  2.  we generally recommend that your primary source be a single @Configuration class. Usually the class that defines the main method is a good candidate as the primary @Configuration
  3. Importing Additional Configuration Classes
    1. You need not put all your @Configuration into a single class
      .
      The @Import annotation can be used to import additional configuration classes.
      Alternatively, you can use @ComponentScan to automatically pick up
      all Spring components, including @Configuration classes.

       

  4. Importing XML Configuration
    1. If you absolutely must use XML based configuration,
      we recommend that you still start with a @Configuration class
      .
      You can then use an @ImportResource annotation to load XML configuration files.