Integration MyBatis is based on the previous project, the previous project specific integration please refer to springboot use one.
I. Integrated MyBatis
Integration of the MyBatis can be downloaded from the MyBatis official website MyBatis website Integrated Project Mybatis-spring-boot-start. Interested in the principle can be studied 21, here only the steps are described.
Introduce dependencies:
<dependency><groupId>org.mybatis.spring.boot</groupId><artifactId> Mybatis-spring-boot-starter</artifactid><version>1.1.1</version></dependency>
<dependency><groupId>ognl</groupId><artifactId>ognl</artifactId><version> 3.1.2</version><scope>test</scope><exclusions><exclusion><groupid> Javassist</groupid><artifactid>javassist</artifactid></exclusion></exclusions> </dependency><dependency><groupid>org.javassist</groupid><artifactid>javassist </artifactId><version>3.20.0-GA</version><scope>test</scope></dependency>
Add the MyBatis related configuration in the Application.properties file:
Mybatis.mapperlocations=sample/mybatis/mapper/*.xmlmybatis.configlocation=classpath:mybatis-config.xml
Logging.level.sample.mybatis.mapper=trace
The mapper related *.xml and mybatis-config.xml are then placed in the corresponding position.
Note: Mybatis-config.xml configuration path is specified, you must add classpath prefix, otherwise you may not find a file error, especially when specifying the project name.
Springboot use: Consolidate MyBatis (XML) and add Pagehelper plugins