整合SM框架时出现的异常
今天在做SM框架整合的时候,出现了如下的错误: 9月 04, 2022 5:58:21 下午 org.springframework.context.support.AbstractApplicationContext refresh 警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘userServiceImpl’: Unsatisfied dependency expressed through field ‘userMapper’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘userMapper’ defined in file [E:IDEAdataspring_SM argetclassescomzzulimapperUserMapper.class]: Unsatisfied dependency expressed through bean property ‘sqlSessionFactory’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.mybatis.spring.SqlSessionFactoryBean#0’ defined in class path resource [applicationcontext_mapper.xml]: Cannot resolve reference to bean ‘dataSource’ while setting bean property ‘dataSource’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘dataSource’ defined in class path resource [applicationcontext_mapper.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type ‘java.lang.String’ to required type ‘java.sql.Driver’ for property ‘driver’; nested exception is java.lang.IllegalStateException: Cannot convert value of type ‘java.lang.String’ to required type ‘java.sql.Driver’ for property ‘driver’: no matching editors or conversion strategy found… 最后发现原来是在application_mapper。xml中的数据源配置出错 这里一定要注意,第一个property标签的name时driverClassName,不要配置成driver,否则你会出现和我一样的错误,以上是我的错误处理,仅供大家学习和参考。
