1. 程式人生 > >mybatis-spring-boot-starter 1.0.1 之後的版本問題

mybatis-spring-boot-starter 1.0.1 之後的版本問題

mapper介面

@MapperScan
public interface PeopleMapper {

    @Select("SELECT * FROM people WHERE id = #{id}")
    People findById(@Param("id") int id);

    @Insert("INSERT INTO people(NAME, AGE) VALUES(#{name}, #{age})")
    int insert(People people);

}

pom

    <dependency>
        <groupId
>
org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.0.1</version> </dependency>

此時mapper是可以正常使用的
但是將mybatis-spring-boot-starter的版本改為1.1.1或者1.3.0之後,則會報錯

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘demo.repository.Dao’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

錯誤資訊詳見spring boot mybatis的問題(提的問題沒人回答。。後來自己回答了,然後在記錄一下)

然後某一天腦袋一抽,想到會不會是註解問題,然後更換註解為@Mapper
mapper介面

@Mapper
public interface PeopleMapper {

    @Select("SELECT * FROM people WHERE id = #{id}")
    People findById(@Param("id") int id);

    @Insert("INSERT INTO people(NAME, AGE) VALUES(#{name}, #{age})"
) int insert(People people); }

pom

    <dependency>
        <groupId>org.mybatis.spring.boot</groupId>
        <artifactId>mybatis-spring-boot-starter</artifactId>
        <version>1.3.1</version>
    </dependency>

發現更換註解後就可照常使用,同測版本1.1.1可用

相關推薦

mybatis-spring-boot-starter 1.0.1 之後版本問題

mapper介面 @MapperScan public interface PeopleMapper { @Select("SELECT * FROM people WHERE id = #{id}") People findById(@Pa

spring boot 整合mybatis 通過官方mybatis-spring-boot-starter

pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XM

使用MyBatis-Spring-Boot-Starter快速整合mybatis

MyBatis-Spring-Boot-Starter是什麼? The MyBatis-Spring-Boot-Starter help you build quickly MyBatis applications on top of the Sprin

lock-spring-boot-starter 1.0.0 正式釋出,輕鬆實現分散式鎖

   lock-spring-boot-starter是一個基於Redisson實現的Spring Boot Starter專案,將分散式鎖的加鎖解鎖基於aop進行封裝,以@Lock註解的方式對外提供服務,使用過程中只需要通過簡單的註解@Lock即可實現分散式鎖,配置容易,上手

Spring boot 總結(1)---Spring-boot-starter-**依賴包說明

1. spring-boot-starter 是Spring Boot的核心啟動器,包含了自動配置、日誌和YAML。 2. spring-boot-starter-amqp 通過spring-rabbit來支援AMQP協議(Advanced Message Queuing P

springboot2.0+dubbo-spring-boot-starter聚合項目打可執行的jar包

inf 惡心 class int reg spa 打包成 tco public springboot2.0+dubbo聚合項目打可執行的jar包 springboot2.0+dubbo-spring-boot-starter項目服務方打包和以前老版本的dubbo打包方式不

springboot2.0整合分頁外掛pagehelper-spring-boot-starter報錯,無法啟動問題

這裡先介紹如何使用springboot2.0整合pagehelper-spring-boot-starter, 新增pom依賴 <dependency> <groupId>com.github.pagehe

spring boot 整合webservice axis(1) eclipse axis外掛安裝

1.下載eclipse的axis外掛 下載地址axis客戶端外掛,axis服務端外掛 2.下載完成  解壓 3.放入eclipse的plugin目錄,我的是\sts\sts-3.8.4.RELEASE\plugins 4.重啟eclipse,右擊專案,點選新建other出現下

spring boot 報錯(1

The content of element type "configuration" must match "(properties?,settings?,typeAliases?,typeHandlers?,objectFactory?... 報錯 如圖: 百度搜

基於Springboot2.0的Dubbo入門專案(dubbo-spring-boot-starter

Dubbo是阿里巴巴公司開源的一個高效能優秀的服務框架,使得應用可通過高效能的 RPC 實現服務的輸出和輸入功能,可以和Spring框架無縫整合。最近半年來,Dubbo的得到了快速的維護,官方也推出了整合Springboot的jar包,及其貼合時代潮流,那麼現在就來講Spri

Spring Boot - An incompatible version [1.2.12] of the APR based Apache Tomcat Native library is...

Spring Boot在目前的專案開發中已經逐步火熱起來,既然是一種技術在使用的過程中出現問題在所難免,在一次初始化Spring Boot專案啟動時,我遇到了一個啟動失敗的問題,日誌給出的資訊An incompatible version [1.1.14] of the APR ba

SpringCloud學習點滴——Spring boot的簡單入門1

因為SpringCloud是在Spring Boot 的基礎上開發的,所以在學習Spring cloud之前,應該要對spring boot有一定的瞭解 一、首先構建一個Spring boot專案:   1、通過官方的Spring Initializr工具產生基礎專案   2、訪問http://star

spring boot連線 sqlserver(1

#spring boot JPA 連線SQl Server 1、首先呢載入jpa 與jdbc 相關的依賴 <dependency> <groupId>org.springframework.boot</groupId>

spring boot 專案重新搭建----------1

1.在resources下建立favicon.ico(訪問的時候會有自己的小圖示) 2.在yml中@[email protected]   #當前伺服器版本 自動讀取MAVEN資訊 @[email protected]格式 version: @[e

Spring原始碼匯入缺少spring-cglib-repack-3.2.9.jar和spring-objensis-repack-3.0.1.jar

如下圖匯入使用gradle轉換後(gradle cleanidea eclipse)的Spring-beans工程報缺少spring-cglib-repack-3.2.9.jar和spring-objensis-repack-3.0.1.jar 解決方法,

Spring Boot學習總結(1)——Spring Boot入門

摘要:Spring Boots是為了幫助開發人員很容易的創建出獨立執行和產品級別的基於 Spring 框架的應用。 從 Spring Boot 專案名稱中的 Boot 可以看出來,Spring

Spring Boot Shiro許可權管理1

原文地址:https://412887952-qq-com.iteye.com/blog/2299732 (1). Shiro簡單介紹 (2). 整合Shiro核心分析 (3). 無Shiro的Spring Boot (4). 整合Shiro 進行使用者授權

微服務架構學習筆記(一):gRPC Spring Boot Starter 2.2.0 釋出,及使用步驟

簡介 gRPC Spring Boot Starter 專案是一個 gRPC 的 Spring Boot 模組。通過在 Spring Boot 中內嵌一個 gRPC Server 對外提供服務,並支援 Spring Cloud 的服務發現、註冊、鏈路跟蹤等等。 更新內容 在 2.

spring boot 學習筆記 (1Spring Boot 介紹

Spring Boot 是一套全新的框架,它來自於 Spring 大家族,因此 Spring 所有具備的功能它都有並且更容易使用;同時還簡化了基於 Spring 的應用開發,通過少量的程式碼就能建立一個獨立的、產品級別的 Spring 應用。 Spring Boot 特性 使用

Spring Boot 學習之路——1 入門demo

前言:使用Spring Boot已有一年多時間,卻從未靜下心來總結,今天抽空寫個傻瓜式教程,鞏固一下。Spring Boot的主要優點:為所有Spring開發者更快的入門開箱即用,提供各種預設配置來簡化專案配置內嵌式容器簡化Web專案沒有冗餘程式碼生成和XML配置的要求(Sp