Liuzh
Liuzh
加注解怎么扫描不到?
`@Transactional` 注解
我在 https://github.com/abel533/MyBatis-Spring-Boot 这个项目做了个测试,没有发现问题。 在这个项目的 CountryService 中,增加了一个 `1/0`,如下: ```java @Transactional(rollbackFor = Exception.class) public void save(Country country) { if (country.getId() != null) { countryMapper.updateByPrimaryKey(country); } else { countryMapper.insert(country); } System.out.println(1/0); } ```
开启 `trace` 级别日志后: ```properties 2017-09-04 21:35:04.938 DEBUG 30456 --- [nio-9090-exec-1] t.m.s.m.C.updateByPrimaryKey : ==> Preparing: UPDATE country SET countryname = ?,countrycode = ? WHERE Id = ? 2017-09-04 21:35:04.960 DEBUG 30456...
去 Example 里面搜 or,方法层次不一样。
能直接搜到很多相关的文章。
https://github.com/abel533/Mybatis-Spring/blob/master/src/main/resources/test.sql 项目中有SQL,并且还有数据。 另外config.properties中增加注释时尽可能不要修改配置信息,每个人的都不一样。 你在看看,可以增加例子或者继续完善,然后PR,谢谢~
看主键策略:https://mapperhelper.github.io/docs/2.use/
有可能支持,但是这么复杂的情况还是手写 xml 逻辑更清晰。
Spring Boot 版本过低引起的,由于 Pagehelper 的 autoconfig 用了特殊的构造参数注入,需要 Spring Boot 版本高点。