@propertySource @ImportResource @Bean

@propertySource (value ={"classpath:......"}

Import the specified configuration file, so that the contents of the configuration file to take effect. SpringBoot there is no configuration file,

We have written profile can not automatically recognize, want a profile take effect, came @ImportResource load marked on a configuration class.

@ImportResource (location = { "classpath: xx.xml"}) // import configuration file

 

@Configuration: indicates the current configuration class is a class configuration, the configuration file is used before Spring alternate

@Bean The return value is added to the vessel, the vessel this component ID is the default method name

@Bean is a comment on a method level, mainly used in @Configuration annotated class, it can also be used in @Component annotated class. Add the bean id is the method name

 

 SpringBoot recommended way to add components to a container

1. Configure class ======== Spring configuration file // Configure class above the class to write on @Configuration

2 used to add components to a container @Bean

 

Guess you like

Origin www.cnblogs.com/shitulaoma/p/12464967.html