MyBatis-Spring-Boot
MyBatis-Spring-Boot copied to clipboard
Spring Boot集成MyBatis的基础项目
几个问题
MyBatisMapperScannerConfig里的bean可以放在MyBatisConfig里吗?我尝试了报错。 我这边两个类里都打印了几句话,打印的信息看到确实是MapperScannerConfig比MyBatisConfig早执行,关键是`basePackage`没法读到配置的值,这个加`@AutoConfigureAfter`也没用,而且加了MapperScannerConfig还比MyBatisConfig 早执行.... ``` @Configuration public class MapperScannerConfig { @Value("${datasource.basePackage:com.tg.ms.mapper}") private String basePackage; @Bean public MapperScannerConfigurer BPMapperScannerConfigurer() { System.out.println("mapper--1.----******----"+basePackage+"----*******"); MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer(); mapperScannerConfigurer.setBasePackage("com.tg.mapper"); mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactoryBean"); return mapperScannerConfigurer; } }...
不知作者写的默认配置如何使用,我对比xml的配置,发现有些不同, PageHelper pageHelper = new PageHelper(); Properties properties = new Properties(); properties.setProperty("offsetAsPageNum", "true"); properties.setProperty("rowBoundsWithCount", "true"); properties.setProperty("pageSizeZero", "true"); properties.setProperty("reasonable", "false"); properties.setProperty("params", "pageNum=pageHelperStart;pageSize=pageHelperRows;"); properties.setProperty("supportMethodsArguments", "false"); properties.setProperty("returnPageInfo", "none"); pageHelper.setProperties(properties);
我采用您的例子,将数据库撤换成h2后,中文乱码。结果: `[ { "id": 1, "page": 1, "rows": 10, "name": "鐭冲搴�", "state": "娌冲寳" }, { "id": 2, "page": 1, "rows": 10, "name": "閭兏", "state": "娌冲寳" } ]` 使用mysql正常,我修改的地方有: MyBatisMapperScannerConfig: `properties.setProperty("IDENTITY",...
代码使用截图  idea调试截图  执行sql  分页配置 