java注解
spring-boot 注解
属性是null 不实例化
可以作用在类上也可以作用在单个属性上
@JsonInclude(JsonInclude.Include.NON_NULL)
可以代替注入 作用在类上
@AllArgsConstructor 配合 final
@Resource
@Autowired
spring bean创建完后 使用@PostConstruct 初始化
创建完对象后要执行的一些操作 不过会映射应用程序的加载时间(非必须少用)
@PostConstruct
public void init() {
staticglobalConfig = globalConfig;
}
controller接收参数时候 如果不用对象 而且多个参数可以用json对象接收
@RequestParam 名字一样可以不写
有三个属性:
(1)value:请求参数名(必须配置)
(2)required:是否必需,默认为 true,即 请求中必须包含该参数,如果没有包含,将会抛出异常(可选配置)
(3)defaultValue:默认值,如果设置了该值,required 将自动设为 false,无论你是否配置了required,配置了什么值,都是 false(可选配置)
@PathVariable,是获取get方式,url后面参数,进行参数绑定/{}/
@Component
创建bean c