1.依赖
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
2. 配置文件
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1/sunlin3?autoReconnect=true&useUnicode=true&characterEncoding=UTF8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: 123456
mybatis:
mapper-locations: classpath:mapper/*Mapper.xml
configuration:
# 开启自动驼峰命名
map-underscore-to-camel-case: true
# 实体类路径,开启自动别名映射
type-aliases-package: com.labelwall.commodity
3. 主类
// dao层的包路径
@MapperScan("com.labelwall.commodity.mapper")
@SpringBootApplication
public class BusinessCommodityApplication {
public static void main(String[] args) {
SpringApplication.run(BusinessCommodityApplication.class, args);
}
}
|