自动运行sql文件
1.修改yml文件:
spring:
datasource:
url: jdbc:mysql://localhost:3306/mydatabase?characterEncoding=UTF-8&&serverTimezone=GMT
username: root
password: 123456
driver-class-name: com.mysql.cj.jdbc.Driver
initialization-mode: always
mybatis:
mapper-locations: classpath:dataImpl/*/*Mapper.xml
用来给数据库添加时区,并且将初始化模式设置成“总是”。不需要自动初始化数据库时只要改成“never”即可。
2.在resources中添加schema.sql文件:
use `mydatabase`;
drop table if exists mytable;
create table mytable(id int primary key auto_increment ,name varchar(20),email varchar(20));
此时编译器飘红,但是不要去管他,运行是ok的。
3.找到DB Browser,添加连接。
如果出现时区错误,只要在mysql数据库的终端添加如下代码:
set global time_zone='+8:00';
运行项目,可以在Browser中发现mytable表已经新建好了。
改变启动时的图标
默认的启动图标是springboot官方图标,如果要修改,只要在resources文件夹下新增banner.txt文件并在其中添加任意字符,启动项目时就会用文件中的字符来代替。