Spring注解

bean声明

@Controller
@Service
@Repository

@Commponent

@Repository、@Service、@Controller,它们分别对应存储层Bean,业务层Bean,和展示层Bean。
@Commponent是一个泛化的概念 ,仅仅表示一个组件,可以用在任何层

bean注入

@Autowired
@Resource
@Inject
@Qualifier
@Bean

其中,inject是java类等价于autowired,只是没有requried,
resource和autowired和区别是:前者byName,后者byType
Qualifier 当多个同类型bean时,使用该注解,配合autowired一起使用。

配置类

@ComponentScan 组件扫描
@Configuration
@Import 导入java类配置
@ImportResource 导入xml文件

@Conditional 条件化 表明需要满足什么样的条件才会引入这个bean

@Aspect 切面


@Bean 只能使用在@Configuration类下的bean引入注解

http

@Controller
@RestController
@RequestMapping
@GetMapping
@PostMapping

@RequestParam

@PathVariable 路径变量

@ControllerAdvice
@InitBinder 日期类等格式转化
@ExceptionHandler

JPA

@Entity
@MappedSuperClass
@NoRepositoryBean
@Column
@Id
@GenerateValue
@Transient
@JoinColunm
@JsonIgnore
@OneToOne
@OneToMany
@ManyToOne

SpringBoot注解

@SpringBootApplication
@EnableConfiguration
@EnableWeb
@EnableAutoConfiguration
@Value

参考文献

spring注解大全
史上最全spring注解