事后调试步骤:
1、MtApiApplication 上增加注解 MapperScan 扫描
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@MapperScan("com.meiti.system.mapper")
public class MtApiApplication
{
public static void main(String[] args)
{
SpringApplication.run(MtApiApplication.class, args);
System.out.println("媒体启动成功!");
}
}
2、因为 有2个依赖 pagehelper-spring-boot-starter 插件 和 mybatis-plus-boot-starter , 会导致 mybatis 版本冲突, 所以移除一个。
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.2</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>${pagehelper.boot.version}</version>
<!-- 版本冲突要移除-->
<exclusions>
<exclusion>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</exclusion>
</exclusions>
</dependency>
3、因为若依MyBatisConfig 类自定义了 sqlSessionFactory , 而mybatis-plus 需要用 MybatisSqlSessionFactoryBean 所以需要替换一下。
@Bean
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception
{
String typeAliasesPackage = env.getProperty("mybatis.typeAliasesPackage");
String mapperLocations = env.getProperty("mybatis.mapperLocations");
String configLocation = env.getProperty("mybatis.configLocation");
typeAliasesPackage = setTypeAliasesPackage(typeAliasesPackage);
VFS.addImplClass(SpringBootVFS.class);
//final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
// SqlSessionFactoryBean 替换为 ⬇️ MybatisSqlSessionFactoryBean
final MybatisSqlSessionFactoryBean sessionFactory = new MybatisSqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
sessionFactory.setTypeAliasesPackage(typeAliasesPackage);
sessionFactory.setMapperLocations(resolveMapperLocations(StringUtils.split(mapperLocations, ",")));
sessionFactory.setConfigLocation(new DefaultResourceLoader().getResource(configLocation));
return sessionFactory.getObject();
}
我遇到的绑定参数问题, 按照以上步骤就解决了,记录于此
参考资料: