Spring boot + Mybatis Generator
首先是pom.xml
中引用所需的依赖
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.27</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mybatis.generator/mybatis-generator-core -->
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.4.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.8</version>
</dependency>
然后需要配置application.yml
spring:
datasource:
url: jdbc:mysql://localhost:3306/mall?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=false
driver-class-name: com.mysql.cj.jdbc.Driver
password: server
username: server
type: com.alibaba.druid.pool.DruidDataSource
mybatis:
# mybatis 扫描的xml文件,**表示任意子文件内的mapper
mapper-locations:
- classpath:mapper/*.xml
- classpath*:com/**/mapper/*.xml
文档信息
- 本文作者:正义的伙伴
- 本文链接:https://ableasd.github.io/2022/03/16/Mybatis/
- 版权声明:自由转载-非商用-非衍生-保持署名(创意共享3.0许可证)