XML configuration
Advantages: Centralized configuration, code configuration separation more convenient management
Disadvantage: Complex, compilation period is not easy to find errors
Javaconfig Configuration
Advantages: Simple Code,
Disadvantage: The domestic XML configuration method is more, not easy to be accepted by people
Steps to use:
1. Write the annotations on the configuration class @configuration identity This class is a configuration class
2. Load custom beans via Componentscan scan (annotations such as @component are configured on the bean)
@ComponentScan (basepackages = {"Com.spmjava.model"}) @Configuration public class Personconfig { }
@Component public class person{ } 3. Using @bea
@Bean Public Cat Getcat () { return new Cat (); }
4. In the Web. XML configuration
Spring javaconfig Configuration instead of XML configuration