org.mybatis.spring.boot
mybatis-spring-boot-starter
1.3.1
org.springframework.boot
spring-boot-starter-web
mysql
mysql-connector-java
runtime
org.springframework.boot
spring-boot-starter-test
test
com.alibaba
druid
1.1.0
org.springframework.boot
spring-boot-maven-plugin
在application.yml中添加数据源、Mybatis的实体和配置文件位置。
#默认使用配置
spring:
profiles:
active: dev
#公共配置与profiles选择无关 mapperLocations指的路径是src/main/resources
mybatis:
typeAliasesPackage: com.xdd.entity
mapperLocations: classpath:mapper/*.xml
#开发配置
spring:
profiles: dev
datasource:
url: jdbc:mysql://localhost:3306/test
username: root
password: root
driver-class-name: com.mysql.jdbc.Driver
使用druid数据源
type: com.alibaba.druid.pool.DruidDataSo