Factory method 'sqlSessionFactory' threw exception; nested exception is com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: Error: GlobalConfigUtils setMetaData Fail ! Cause:java.lang.RuntimeException: Driver com.mysql.cj.jdbc.Driver claims to not accept jdbcUrl, jdbc:hsqldb:mem:testdb
时间: 2023-07-14 07:55:15 浏览: 183
这是Mybatis-Plus框架的异常,可能是因为配置文件中的数据库驱动配置有误导致的。具体原因是由于Mybatis-Plus默认使用了Druid数据源,但是在使用MySQL数据库时,需要使用MySQL提供的JDBC驱动而不是Druid提供的JDBC驱动。请检查你的配置文件,确保数据库驱动的配置正确,并且与你使用的数据库相匹配。同时,也可以尝试将Druid数据源替换为其他数据源,比如HikariCP,以解决这个问题。
相关问题
Error creating bean with name 'courseController': Unsatisfied dependency expressed through field 'courseService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'courseServiceImpl': Unsatisfied dependency expressed through field 'courseMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'courseMapper' defined in file [D:\wnnj_workspace\phase3\coureselection\target\classes\com\wnnj\coureselection\mapper\CourseMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\wnnj_workspace\phase3\coureselection\target\classes\mapper\CourseMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'file [D:\wnnj_workspace\phase3\coureselection\target\classes\mapper\CourseMapper.xml]'. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'course'. Cause: java.lang.ClassNotFoundException: Cannot find class: course
这个错误是由于在创建名为'courseController'的bean时出现了依赖问题。具体原因是在创建名为'courseServiceImpl'的bean时,出现了依赖问题,该bean依赖于名为'courseMapper'的bean。而在创建'courseMapper'时,又出现了依赖问题,该bean依赖于'CourseMapper.xml'文件中定义的'sqlSessionFactory'。最终导致的错误是在解析'Mapper XML'文件时出现了问题。
具体来说,错误信息指出了一个类别名解析失败的问题。它无法解析别名为'course'的类。可能的原因是找不到该类的定义,导致无法解析。
要解决这个问题,你可以检查以下几点:
1. 确保'course'类存在,并且已经添加到项目中。
2. 确保在'Mapper XML'文件中正确地引用了'course'类,并且类路径正确。
3. 如果使用了MyBatis Plus框架,确保配置文件中的类型别名设置正确。
通过检查和修复上述问题,应该能够解决这个错误。如果问题仍然存在,请提供更多的代码和配置信息,以便我更好地帮助你解决问题。
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'argueController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'argueMapper' defined in file [D:\IDEA-2021.1.3\Project\yc-learn\myblog\myblog\target\classes\com\example\myblog\mapper\ArgueMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class
这个异常是由于在初始化过程中遇到了错误导致的。具体错误信息是关于依赖注入失败的问题,其中涉及到了一个名为'argueController'的bean以及'argueMapper'和'sqlSessionFactory'的创建问题。
在这个异常信息中还提到了一个与数据库连接相关的问题,即在创建dataSource时出现了错误。具体的错误信息是无法确定合适的驱动程序类。
这些错误可能是由于配置文件或依赖项的问题引起的。建议检查相关的配置文件,确保数据库连接配置正确,并且所有必要的依赖项都已正确引入。如果需要进一步帮助,请提供更多的详细信息。
阅读全文