Spring Boot 启动时出现 'Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.' 错误,并提示 'Binding to target [Bindable@2de96727 type = java.lang.String[], value = 'provided', annotations = array[[empty]]] failed',通常是由于 mybatis.mapper-locations 属性配置错误导致的。

错误信息:

2023-05-28 22:31:22.195 ERROR 17032 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Binding to target [Bindable@2de96727 type = java.lang.String[], value = 'provided', annotations = array<Annotation>[[empty]]] failed:

    Property: mybatis.mapper-locations[0].classpath
    Value: /mapper/*/*.xml
    Origin: class path resource [application.yml]:36:18
    Reason: The elements [mybatis.mapper-locations[0].classpath] were left unbound.

Action:

Update your application's configuration

错误原因:

未能将属性 'mybatis.mapper-locations[0].classpath' 绑定到目标上,导致启动应用程序失败。可能的原因是该属性没有正确的配置或配置了错误的格式。

解决方法:

  1. 检查配置文件中的 'mybatis.mapper-locations' 属性: 确保该属性的值为正确的路径,例如:
mybatis:
  mapper-locations:
    - classpath:/mapper/*/*.xml
  1. 检查配置文件的格式: 确保配置文件的格式正确,例如 YAML 文件的缩进。

  2. 检查 Mybatis 依赖: 确保 Mybatis 的依赖版本正确。

  3. 检查 mapper 文件路径: 确保 mapper 文件的路径与配置文件中的路径一致。

  4. 检查数据库连接: 确保数据库连接配置正确。

如果以上步骤都无法解决问题,建议查看 Spring Boot 的官方文档或搜索相关错误信息。

Spring Boot 启动失败: mybatis.mapper-locations 绑定错误

原文地址: https://www.cveoy.top/t/topic/okak 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录