SpingBoot整合Mybatis

一、创建springboot项目并导入相关依赖

   

<dependency>

<groupId>com.alibaba</groupId>

<artifactId>druid-spring-boot-starter</artifactId>

<version>1.1.10</version>

</dependency>

   

<dependency>

<groupId>mysql</groupId>

<artifactId>mysql-connector-java</artifactId>

<scope>runtime</scope>

<version>5.1.27</version>

</dependency>

   

注:maven建议把mybatis的xml文件(也是mybatis查询写sql语句的xml)放在recourse文件下,所以运行的时候会跳过src/main/java下的xml,所以加上如下配置

   

SpingBoot整合Mybatis

<resources>

<resource>

<directory>src/main/java</directory>

<includes>

<include>**/*.xml</include>

</includes>

</resource>

<resource>

<directory>src/main/resouce</directory>

</resource>

</resources>

上一篇:SpingBoot注解


下一篇:spingboot项目,定义参数到配置文件并获取