@Override
重写,主要用于确定当前方法正确重写了父类的方法
@Test
测试方法,用于标记测试方法
@Deprecated
方法已过时
@SafeVarargs
堆污染,没遇到过还
注解名称 | 作用对象 | 功能 | 包 |
---|---|---|---|
@Component | 类 | 表示此类会被Spring容器自动创建对象,并添加到容器,key是类名的首字母小写 | org.springframework.stereotype |
@Controller | 类 | 等同于@Component ,用于标识此类为与前端交互处理程序 | org.springframework.stereotype |
@Service | 类 | 等同于@Component ,用于标识此类为业务处理程序 | org.springframework.stereotype |
@Repository | 类 | 等同于@Component,用于标识此类为实现数据库的相关操作的处理程序 | org.springframework.stereotype |
@Configuration | 类 | 声明此类为一个配置类 | org.springframework.context.annotation |
@ComponentScan("cn.tedu") | @Configuration | 与@Configuration 注解一起使用,用于指明该配置类需要扫描的包路径,也会扫描其子孙包 | org.springframework.context.annotation |
@Scope | @Bean | 标明作用域,如单例、多例 | org.springframework.context.annotation |
@Lazy | @Bean | 标识该Bean延迟到使用时才加载(类比单例模式中的懒汉式)单例模式下所有的bean是初始化容器时直接就加载了,使用了@Lazy 注解后,对应的bean会延迟到使用时才会加载 | org.springframework.context.annotation |
@PostConstruct | 方法 | 注解标识的方法会在对象被创建后(即构造函数执行后)被自动调用 | javax.annotation |
@PreDestroy | 方法 | 注解标识的方法会在销毁对象之前被自动调用 | javax.annotation |
@Autowired | 属性、set方法 | 将由容器管理的该属性对应的对象或其子实现类的对象注入到当前引用变量中 | org.springframework.beans.factory.annotation |
@Qualifier | @Autowired | 如果一个类型有多个子实现类,需要手动指定要注入哪一个实现类时,可以使用此注解来指定 | org.springframework.beans.factory.annotation |
@Value @Value("#{'${user.hobbys}'.split(',')}") @Value("${user.username}") | 属性、set方法 | 可以向属性或set方法中的属性注入指定的值或配置文件中的值 | org.springframework.beans.factory.annotation |
@PropertySource("classpath:/user.properties") | 类 | 用于引入src/main/resources文件夹下的properties文件 | org.springframework.context.annotation |
@EnableAspectJAutoProxy | 启动类上 | 用于标识启动切面功能 | org.springframework.context.annotation |
@Aspect | 类 | 标识此类为一个切面类 | org.aspectj.lang.annotation |
@Pointcut("bean(beanId)") | 方法 | 标识该方法为一个切入点表达式签名 | org.aspectj.lang.annotation |
@Around("@annotation(pri)") | 方法 | 标识该方法为目标方法的环绕方法 | org.aspectj.lang.annotation |
@Before("pointCutHandler()") | 方法 | 标识该方法为目标方法的前置方法 | org.aspectj.lang.annotation |
@After("pointCutHandler()") | 方法 | 标识该方法为目标方法的后置方法 | org.aspectj.lang.annotation |
@AfterReturning("pointCutHandler()") | 方法 | 标识该方法为目标方法返回结果后执行的方法 | org.aspectj.lang.annotation |
@AfterThrowing("pointCutHandler()") | 方法 | 标识该方法为目标方法抛出异常时执行的方法 | org.aspectj.lang.annotation |
@Order() | 切面类 | 用于标识该切面类在实际加载切面类时的顺序,值小者优先 | org.springframework.core.annotation |
@Controller | 类 | 用于标识该类为Controller类,交由bean容器管理 | org.springframework.stereotype |
@ResponseBody | 类或方法 | 用于标识该类或该方法的返回值如果是个对象,则转成JSON格式的字符串 | org.springframework.web.bind.annotation |
@RestController | 类 | 等于@ResponseBody +@Controller | org.springframework.web.bind.annotation |
@RequestMapping | 类或方法 | 标识该类的根请求路径或该方法的最后一级请求路径 | org.springframework.web.bind.annotation |
@GetMapping("/add") | 类或方法 | 标识该类的根请求路径或该方法的最后一级请求路径,限定请求类型只能是GET响应 | org.springframework.web.bind.annotation |
@PutMapping("updateUser") | 类或方法 | 标识该类的根请求路径或该方法的最后一级请求路径,限定请求类型只能是PUT响应 | org.springframework.web.bind.annotation |
@PostMapping("updateUser") | 类或方法 | 标识该类的根请求路径或该方法的最后一级请求路径,限定请求类型只能是PUT响应 | org.springframework.web.bind.annotation |
@DeleteMapping("updateUser") | 类或方法 | 标识该类的根请求路径或该方法的最后一级请求路径,限定请求类型只能是DELETE响应 | org.springframework.web.bind.annotation |
@CrossOrigin | 类或方法 | 标识该类下面所有的请求或该请求支持跨域访问 | org.springframework.web.bind.annotation |
@SpringBootApplication | 类 | 标识该类为SpringBoot的启动类 | org.springframework.boot.autoconfigure |
@Data | 类 | 提供类所有属性的 getting 和 setting 方法,此外还提供了equals、canEqual、hashCode、toString 方法 | lombok |
@Setter | 属性 | 为属性提供 setting 方法 | lombok |
@Getter | 属性 | 为属性提供 getting 方法 | lombok |
@NoArgsConstructor | 类 | 为类提供一个无参的构造方法 | lombok |
@AllArgsConstructor | 类 | 为类提供一个全参构造方法 | lombok |
@Accessors(chain = true) | 类 | 标识该类的setter方法支持链式调用 | lombok |
@SpringBootTest | 类 | 标识该类为SpringBoot容器测试类,其下所有的测试方法会在整个SpringBoot容器启动后再进行测试 | org.springframework.boot.test.context |
@mapper | mapper接口 | 表示将该接口交由Spring容器管理 | org.apache.ibatis.annotations |