Spring boot 集成mybatis

参考链接:

http://412887952-qq-com.iteye.com/blog/2303121

http://blog.didispace.com/springbootmybatis/

http://www.mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/

 

maven 依赖:

       <dependency>

   <groupId>mysql</groupId>

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

</dependency>

<dependency>

<groupId>org.mybatis.spring.boot</groupId>

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

<version>1.1.1</version>

</dependency>

<dependency>

        <groupId>com.github.pagehelper</groupId>

        <artifactId>pagehelper</artifactId>

        <version>4.1.6</version>

    </dependency>

 

另外spring boot读取mapper是需要使用@Mapper注解,@Responsity注解怎么都没有扫描到

Advanced scanning

MyBatis-Boot-Starter will search, by default, for mappers marked with the @Mapper annotation.

You may want to specify a custom annotation or a marker interface for scanning. If so, you must use the @MapperScan annotation. See more about it in the MyBatis-Spring reference page.

MyBatis-Boot-Starter will not start the scanning process if it finds at least one MapperFactoryBean in the Spring's context so if you want to stop the scanning at all you should register your mappers explicitly with @Bean methods.

 

 

mybatis分页可以使用 PageHelper

 

如果查询的是List,那么使用mybatis注解方式的  @Results

 

猜你喜欢

转载自slnddd.iteye.com/blog/2339553