zl程序教程

您现在的位置是:首页 >  其他

当前栏目

解决:java.lang.IllegalStateException: Property ‘configuration‘ and ‘configLocation‘ can not specified

2023-03-14 22:37:39 时间

本例环境: springboot + IntelliJ IDEA 

报错信息:image

解决:

   在springboot的application.yml不能同时使用以下两个配置,换句话说,两者配置方式只能取其一.

   mybatis:
        config-location: classpath:mybatis/mybatis-config.xml
        configuration:
            map-underscore-to-camel-case: true

正确方式一:

   mybatis:
        # 指定全局配置文件位置
        config-location: classpath:mybatis/mybatis-config.xml
        # 指定sql映射文件位置
       mapper-locations: classpath:mybatis/mapper/*.xml

正确方式二:

   # 指定sql映射文件位置
   mybatis:
       mapper-locations: classpath:mybatis/mapper/*.xml
       configuration:
           map-underscore-to-camel-case: true

以上,TKS.