有个xml文件的类型与其mapper名不一致,
调用接口时,提示
Invalid bound statement (not found)
MbgOrderDao.java 与MbgOrderDao.xml
xml的存放路径与Dao的包路径不一致
调用接口时,提示
Invalid bound statement (not found)
测试环境(一直没有问题)
application.yml中配置了
mybatis: mapper-locations: - classpath:dao/*.xml - classpath*:com/**/mapper/**/*.xml application-dev.yml mybatis: mapper-locations: classpath: dao/*Dao.xml正式环境(MbgOrderDao报Invalid bound statement (not found) )
application.yml中配置了
mybatis: mapper-locations: - classpath:dao/*.xml - classpath*:com/**/mapper/**/*.xml application-prod.yml mybatis: mapper-locations: classpath:dao/*Dao.xmlapplication-dev.yml中的mybatis:mapper-locations: 的值带空格,覆盖了application.yml的中mybatis:mapper-locations:
application-prod.yml中的mybatis:mapper-locations: 的值不带空格,没有覆盖覆盖了application.yml的配置classpath
知识点3:
mybatis: configuration: log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 打印sql 返回值 也可打印扫描的xml文件,但是xml与mapper同路径时且未配置此处扫描路径,则不打印()知识点4:答应mybatis读取的配置
public class Application implements CommandLineRunner{ @Autowired MybatisProperties mybatisProperties; public static void main(String[] args) { SpringApplication.run(MallPortalApplication.class, args); } @Override public void run(String... args) throws Exception { String[] argss = mybatisProperties.getMapperLocations(); System.out.printf(StringUtils.join(argss)); } }
