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

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值