Spring注解分类

作者: 技术灭霸 | 来源:发表于2020-05-26 13:46 被阅读0次
image.png

1、SpringBoot相关注解

@SpringBootApplication
@EnableAutoConfiguration
@SpringBootConfiguration

2、请求相关注解

@Controller
@ResponseBody
@RestController
@RequestMapping、@GetMapping、@PostMapping、@PutMapping、@DeleteMapping、@PatchMapping
@RequestParam
@PathVariable
@ResponseStatus
@CookieValue
@ModelAttribute
@CrossOrigin
@EnableWebMvc

3、Bean相关注解

@ComponentScan
@Service
@Repository
@Component
@Autowired
@Resource
@Qualifier
@Inject
@Bean
@DependsOn
@Primary
@Data
@Setter和@Getter
@NoArgsConstructor、@RequiredArgsConstructor、@AllArgsConstructor
@EqualsAndHashCode
@toString
@NonNull
@val
@Scope

4、 配置文件注解

@EnableConfigurationProperties
@Configuration
@Value
@ConfigurationProperties
@AutoConfigureBefore、@AutoConfigureAfter、@AutoConfigureOrder
@ContextConfiguration
@Import
@ImportResource
@Required
@PropertySource

5、JSON转化相关注解

@JsonIgnoreProperties
@JsonIgnore
@JsonFormat
@JsonSerialize
@JsonDeserialize
@JsonProperty

6、Mybatis相关注解

@Mapper
@MapperScan
@Param
@Insert、@Select、@Update、@Delete
@Results
@Result
@One
@Many

7、AOP相关注解

@EnableAspectJAutoProxy
@Aspect
@PointCut
@Before、@Around、@After
@AfterReturning
@AfterThrowing

8、缓存相关注解

@EnableCaching
@SessionAttributes
@Cacheable
@CacheEvict

9、事务相关注解

@EnableTransactionManagement
@Transactional

10、Bean的生命周期注解

@PostConstruct
@PreDestory

11、 异步相关注解

@EnableAsync
@Async

12、任务相关注解

@EnableScheduling
@EnableScheduling
@Scheduled

13、条件配置注解

@Conditional
@ConditionalOnBean、@ConditionalOnMissingBean
@ConditionalOnClass、@ConditionalOnMissingClass
@ConditionalOnWebApplication、@ConditionalOnNotWebApplication
@ConditionalOnSingleCandidate
@ConditionalOnExpression
@ConditionalOnProperty
@ConditionalOnResource
@ConditionalOnJndi
@ConditionalOnJava

14、 JPA相关注解

@EnableJpaRepositories
@Entity
@Table
@Id
@GeneratedValue
@Column
@ColumnComment
@Transient
@Temporal
@Enumerated
@Embedded、@Embeddable
@ElementCollection
@CreatedDate、@CreatedBy、@LastModifiedDate、@LastModifiedBy
@MappedSuperClass
@NoRepositoryBean
@SequenceGeneretor
@JoinColumn
@OneToOne、@OneToMany、@ManyToOne
@PostLoad
@PrePersist和@PostPersist
@PreUpdate和@PostUpdate
@PreRemove和@PostRemove
@EnableJpaAuditing

15、 元注解

@Target
@Retention
@Documented
@Inherited

16、日志相关注解

@Log4j
@Log4j2

17、 全局异常处理注解

@ControllerAdvice
@ExceptionHandler

相关文章

网友评论

    本文标题:Spring注解分类

    本文链接:https://www.haomeiwen.com/subject/amgmahtx.html