Consider defining a bean of type 'com.xxx.mapper.XsMapper' in your configuration
阿新 • • 發佈:2020-12-02
詳細描述:
Field xsMapper in com.xxx.controller.XsController required a bean of type 'com.xxx.mapper.XsMapper' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'com.xxx.mapper.XsMapper' in your configuration.
解決:
這個是沒有指定mybatis掃包的範圍,sb不知道去哪裡裝載。
1)在Application類中指定掃包的範圍
@MapperScan("包"),包:就是你的Mapper Interface所在包
2)可以直接在類上面加註解
直接在mapper介面上加@Mapper
說明:
如果二個都加行不行?答案:不行。
如果找不到:@MapperScan,應該咱辦呢?
那肯定是要加入一個mybatis的
<dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.2.0</version> </dependency>
這樣就OK了。二種方案,二選一。