org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): cn.com.bofeng.pipihealth.database.mapper.rule.RuleServiceIndicatorsDetailMapper.selectList
- Check whether I introduce mybatis plus dependencies
In the
official website, the introduction of mybatis plus depends on the following
<!-- spring boot -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.1</version>
</dependency>
<!-- spring -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus</artifactId>
<version>3.5.1</version>
</dependency>
After introducing MyBatis-Plus, please do not introduce Mybatis and MyBatis-Spring again to avoid problems caused by version differences.
- Delete mybatis other dependencies that cause conflicts
Check whether other Mybatis dependencies are introduced in the POM file. If there is the following dependencies, you can directly annotate:
<!-- spring boot -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.0</version>
</dependency>
<!-- spring -->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.4</version>
</dependency>
- Spring Boot SQLSESSIONFACTORY BeAN configuration
@Configuration
public class MybatisPlusConfig {
@Value("${mybatis.mapper-locations}")
private String mapperLocations;
// spring boot
@Bean
public SqlSessionFactory sqlSessionFactory(DataSource dataSource)
throws Exception {
final MybatisSqlSessionFactoryBean sessionFactory = new MybatisSqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(mapperLocations));
return sessionFactory.getObject();
}
}
- Spring Boot SQLSESSIONFACTORY BeAN configuration
<!-- spring -->
<bean id="sqlSessionFactory" class="com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:/mybatis.xml"/>
<property name="mapperLocations">
<array>
<value>classpath*:/mapper/**/*.xml</value>
</array>
</property>
</bean>