Spring 注解大全

Spring项目中会用到大量的注解,这里罗列以下常用的。除过这些外SpringBoot、SpringSecurity、SpringData等也有大量的注解。

可以通过package去查看官方文档里的具体说明,比如:
[url=http://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/package-summary.html]http://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/context/annotation/package-summary.html[/url]
Annotation Types Summary部分就是该package下所有注解的说明。
[img]http://dl2.iteye.com/upload/attachment/0123/6835/12257cee-41c7-3706-9934-85d295933c15.png[/img]

[b](1)Context[/b] [color=blue]org.springframework.context.annotation[/color]
@Configuration
@ComponentScan
@ComponentScans
@Conditional
@Bean
@Lazy
@DependsOn
@Import
@ImportResource
@Primary
@Profile
@Scope
@Description
@PropertySource
@PropertySources
@Role

[b](2)Bean[/b] [color=blue]org.springframework.beans.factory.annotation[/color]
@Autowired
@Qualifier
@Required
@Scope
@Lookup
@Value
@Configurable

[b](3)Core[/b] [color=blue]org.springframework.core.annotation[/color]
@Order
@AliasFor

[b](4)Stereotyping[/b] [color=blue]org.springframework.stereotype[/color]
@Component
@Controller
@Service
@Repository

[b](5)Web[/b] [color=blue]org.springframework.web.bind.annotation[/color]
@Controller
@ControllerAdvice
@InitBinder
@ModelAttribute
@MatrixVariable
@RequestMapping
@RequestParam
@RequestPart
@RequestBody
@RequestHeader
@RequestAttribute
@SessionAttribute
@SessionAttributes
@CookieValue
@ExceptionHandler
@CrossOrigin

@GetMapping
@PostMapping
@PutMapping
@DeleteMapping
@PatchMapping

@RestController
@RestControllerAdvice
@ResponseBody
@ResponseStatus
@PathVariable

[b](6)Transaction[/b] [color=blue]org.springframework.transaction.annotation[/color]
@EnableTransactionManagement
@Transactional

[b](7)Cache[/b] [color=blue]org.springframework.cache.annotation[/color]
@EnableCaching
@CacheConfig
@Cacheable
@Caching
@CachePut
@CacheEvict

[b](8)Schedule[/b] [color=blue]org.springframework.scheduling.annotation[/color]
@EnableAsync
@Async
@EnableScheduling
@Scheduled
@Schedules

[b](9)Aspect[/b] [color=blue]org.aspectj.lang.annotation[/color]
@Aspect
@After
@AfterReturning
@AfterThrowing
@Around
@Before
@DeclareParents
@Pointcut

[b](10)JSR-250[/b] [color=blue]javax.annotation[/color]
@PostConstruct
@PreDestroy
@Resource

[b](11)JSR-330[/b] [color=blue]javax.inject[/color]
@Inject
@Named

[b](12)JSR-303[/b] [color=blue]javax.validation.constraints[/color]
@Max
@Min
@NotNull
@Size
@Pattern
@Valid

[b]Hibernate Validator[/b] [color=blue]org.hibernate.validator.constraints[/color]
@Email
@Length
@Digits
@NotEmpty
@NotBlank
@Range
@URL
@Past
@Future

[b](13)MyBatis[/b] [color=blue]org.apache.ibatis.annotations[/color]
@Param
@Select
@Update
@Delete
@Insert
@Results
@Result
@Options

[b](14)其他[/b]
@EnableWebMvc org.springframework.web.servlet.config.annotation
@Validated org.springframework.validation.annotation
@MapperScan org.mybatis.spring.annotation
@Alias org.apache.ibatis.type.Alias

[img]http://dl2.iteye.com/upload/attachment/0130/9934/694ce90a-03ec-3c21-b076-c498dd542548.png[/img]

[url=https://dzone.com/articles/15-spring-core-annotations-with-examples]https://dzone.com/articles/15-spring-core-annotations-with-examples[/url]

参考:
[url=https://dzone.com/refcardz/spring-annotations]https://dzone.com/refcardz/spring-annotations[/url]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值