Spring的几个annotation

@SpringBootApplication

Indicates a @Configuration class that declares one or more @Bean methods and also trigger @EnableAutoConfiguration and @ComponentScan. This is a convenience annotation that is equivalent to delcaring @Configuration, @EnableAutoConfiguration,@ComponentScan.

@Configuration

package org.springframework.context.annotation;

Indicates that a class declares one or more Bean methods and may be processed by the Spring container to generate bean definitions and service requests for those beans at runtime.

@EnableAutoConfiguration

Enable auto-configuration of the Spring Application Context, attempting to guess and configure beans that you are likely to need. Auto-configuration classes are usually applied based on your classpath and what beans you have defined. For example, if you have tomcat-embedded.jar on your classpath you are likely to want a TomcatServletWebServerFactory (unless you have defined your own ServletWebServerFactory bean).

@ComponentScan

@ImportResource

Indicates one or more resources containg bean definitons to import.

@Bean

Indicates that a method produces a bean to be managed by the Spring container.

@RestController
package org.springframework.web.bind.annotation;

A convenience annotation that is itself annotated with @Controller and @ResponseBody

猜你喜欢

转载自blog.csdn.net/morning_china/article/details/82782195
今日推荐