SpringBoot常见错误

933 阅读1分钟

class path resource

类路径资源缺失

  • 场景1:直接复制其他工程文件,可能会导致该问题,此时需要新建文件,选择复制工程文件的内容。(解决:右键该复制而来的文件 Build Module "****")

Mapped Statements collection already contains value for **.mapper.QuestionMapper.list.

一个mapper中不可以有两个相同名称的方法,即使方法参数不一样,也是不可以的。

application.yml文件配置错误

java.lang.IllegalStateException: Failed to load property source from location 'classpath:/application.yml'

Caused by: org.yaml.snakeyaml.scanner.ScannerException: mapping values are not allowed here in 'reader', line 27, column 21: mapper-locations: classpath:mapper/*.xml

mybatis中dao接口与mapper配置文件在做映射绑定的时候出现问题

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

<!-- 错误 -->
mybatis:
  configuration:
    map-underscore-to-camel-case: true
    type-aliases-package: life.majiang.community.mapper
    mapper-locations: classpath:mapper/*.xml
<!-- 正确 -->
mybatis:
  configuration:
    map-underscore-to-camel-case: true
  type-aliases-package: life.majiang.community.mapper
  mapper-locations: classpath:mapper/*.xml

解决

  1. cause by
  2. root Cause