springboot整合mybatis+mysql+druid数据源
导入依赖包
org.mybatis.spring.boot
mybatis-spring-boot-starter
2.0.1
mysql
mysql-connector-java
runtime
com.alibaba
druid
1.1.16
在pom.xml文件中添加如下
src/main/java
**/*.xml
src/main/resources
在application.yml中添加配置
spring:
datasource:
url: jdbc:mysql://39.97.234.52:3306/LearnWeb?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=Asia/Shanghai
username: root
password: root
type: com.alibaba.druid.pool.DruidDataSource
在启动类上添加注解@MapperScan注解,扫描mapper.xml文件所在的位置
@SpringBootApplication
@MapperScan("com.example.vueblog.mapper")
public class VueblogApplication {
public static void main(String[] args) {
SpringApplication.run(VueblogApplication.class, args);
}
}