SpringBoot获取文件总的来说有三种方式,分别是@Value注解,@ConfigurationProperties注解和Environment接口。这三种注解可以配合着@PropertySource来使用,@PropertySource主要是用来指定具体的配置文件。@PropertySource解析@Target(ElementType.TYPE)@Retention(RetentionPo
分类:
编程语言 时间:
2020-07-08 11:41:26
阅读次数:
68
1 判断某个注解是否存在 判断某个注解是否存在于Class、Field、Method或Constructor: Class.isAnnotationPresent(Class) Field.isAnnotationPresent(Class) Method.isAnnotationPresent(C ...
分类:
其他好文 时间:
2020-07-06 19:43:38
阅读次数:
63
概念 AOP(Aspect-OrientedProgramming,面向切面编程),可以说是OOP(Object-Oriented Programing,面向对象编程)的补充和完善。 (1)Aspect(切面):通常是一个类,里面可以定义切入点和通知 (2)JointPoint(连接点):程序执行过 ...
分类:
其他好文 时间:
2020-06-24 20:03:55
阅读次数:
49
Spring中存在很多注解组合的情况,例如**@RestController** @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Documented @Controller @ResponseBody public @i ...
分类:
编程语言 时间:
2020-06-24 00:48:07
阅读次数:
78
@SpringBootConfiguration注解表示Spring Boot配置类。查看@SpringBootConfiguration注解源码,核心代码具体如下。 ```java @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUN ...
分类:
编程语言 时间:
2020-06-22 10:48:52
阅读次数:
71
增加对annotation的支持,查找@Controller下的@RequestMapping 代码:https://github.com/kuotian/springmvc_me 1. 注解 @Controller @Target(ElementType.TYPE) @Retention(Rete ...
分类:
编程语言 时间:
2020-06-18 22:13:41
阅读次数:
66
【转-整理】 JAXB注解 @XmlRootElement 及XML文件解析详解 Java代码 @Retention(value=RUNTIME) @Target(value=TYPE) public @interface XmlRootElement @Inherited @Retention(v ...
分类:
其他好文 时间:
2020-06-16 01:18:25
阅读次数:
83
1. 元注解@Inherited继承 package com.example.demo; import java.lang.annotation.*; import java.util.Arrays; public class Test { public static void main(Strin ...
分类:
编程语言 时间:
2020-06-13 21:12:40
阅读次数:
62
自定义注解基于元注解来定义自己所需要的注解 @Documented@Target(FIELD) @Retention(RUNTIME) public @interface IdcardValidate { String message() default "身份证号不正确"; Class<?>[] ...
分类:
其他好文 时间:
2020-06-10 23:06:55
阅读次数:
98
案例一、角色校验 项目中,对某些方法需要用户具备指定角色权限才能执行。 /** * 角色校验注解 */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface HasRole { String ...
分类:
编程语言 时间:
2020-06-09 18:18:54
阅读次数:
68