1、sql脚本数据源初始化
与 DataSource 初始化相关的 spring.datasource.* 属性已被弃用,新的属性为 spring.sql.init.* 。初始化数据库时的属性,例如项目启动新建数据库的建表语句等,并非连接数据的数据源配置。
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/javastack
username: root
password: 12345678
sql.init:
schemaLocations:
- classpath:sql/create_t_javastack.sql
dataLocations:
- classpath:sql/insert_t_javastack.sql
总是初始化一个数据库配置为
spring.sql.init.mode=always
如果禁用则配置为
spring.sql.init.mode=never
2、springdata-jpa
Spring Data JPA引入了一个新的 getById 方法,它取代了 getOne 。如果现在的程序启动报 LazyLoadingException 异常,将现在的 getById 方法重命名为 getXyzById (其中 xyz 是一个任意字符串)。
3、Hibernate Validate的默认版本已经升级到6.2.x
4、为系统环境变量指定前缀
例如,下面将添加一个 myapp 前缀:
SpringApplication application = new SpringApplication(MyApp.class);
application.setEnvironmentPrefix("myapp");
application.run(args);
此时可以声明环境变量MYAPP_xxx,例如设置环境变量启动端口号:MYAPP_SERVER_PORT。
5、java支持
支持java16及向下兼容java8。