springboot2的特性
配置文件绑定
在Spring Boot 2.0中对配置属性加载的时候会除了像1.x版本时候那样移除特殊字符外,还会将配置均以全小写的方式进行匹配和加载。所以,下面的4种配置方式都是等价的:
spring.jpa.databaseplatform=mysql
spring.jpa.database-platform=mysql
spring.jpa.databasePlatform=mysql
spring.JPA.database_platform=mysql
spring:
jpa:
databaseplatform: mysql
database-platform: mysql
databasePlatform: mysql
database_platform: mysql
在properties文件中使用[]来定位列表类型,比如:
Spring Boot 2.0中对于List类型的配置必须是连续的,不然抛出异常
Map类型
- properties格式
spring.my-example.foo=bar
spring.my-example.hello=world
- yaml格式
spring:
my-example:
foo: bar
hello: world
如果Map类型的key包含非字母数字和-的字符,需要用[]括起来
@Data注解的作用:通过注解的形式自动生成构造器、getter/setter、equals、hashcode、toString等方法,提高了一定的开发效率
让代码变得简洁,不用过多的去关注相应的方法
属性做修改时,也简化了维护为这些属性所生成的getter/setter方法等
缺点:降低了代码的可读性,不支持多种参数构造器的重载
详解
@Autowired注解
@Autowired
佬,找工作的化,django和sprinboot是都学,还是建议只学一个
目前python和java都基础语法都会点