springboot整合Mybatis 配置通用Mapper
按照網上部落格上寫的加上了pom依賴後,啟動之後呼叫通用Mapper的方法就會報BaseSelectProvider無法初始化的錯。
百度一番之後解決方法如下:
pom依賴:
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper</artifactId>
<version>3.3.9</version>
</dependency>
<dependency>
<!-- 就是加了一個springboot專用的stater後就OK了 -->
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>1.1.5</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>5.1.2</version>
</dependency>
另外,springboot的mapperscan掃描的包不能包含通用Mapper。
@SpringBootApplication
@ComponentScan(basePackages={"com.lengwenting.pm"})
@MapperScan(basePackages={"com.lengwenting.pm.*.dao"})
@EnableSwagger2
public class PMApplication {
public static void main(String[] args) {
SpringApplication.run(PMApplication.class);
}
}