idea,better-mybatis-generator,mysql8
1.首先去在idea的setting中找插件库(plugins)找到这个插件,然后下载。
2.保证application配置文件里有数据库连接的配置(因为是mysql8,最后需要有时区设置)
我的是application.yml文件,配置了多数据库,截取了默认连接,注意最后的serverTimezone=GMT,设置时区
spring:
datasource:
#primary一般是默认源
primary:
jdbc-url: jdbc:mysql://localhost:3306/mydatabase?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=GMT
username: root
password: leaves
driver-class-name: com.mysql.cj.jdbc.Driver
3.然后在pom下添加依赖
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
4.配置application.yml
#mybatis
mybatis:
mapper-locations: classpath:generator/*.xml
logging:
level:
com.leaf.boot.launchs: debug
5. 主程序中配置
@MapperScan(basePackages = {"com.leaf.boot.launch.generator"})
//我这里bootlaunch是项目名,com.leaf是组名