Spring整合Mybatis遇到的错误
1、
Error creating bean with name 'datasource' defined in class path resource [application.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
问题决绝办法:
在使用DruidDatasource时候 使用了driver 属性,而这个属性需要的是一个Dirver驱动,而我的却是一个String类型
所以只需要把 driver改为driverClassName就运行成功啦
2、
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sqlSessionFactroy' defined in class path resource [application.xml]:
Error setting property values;
nested exception is org.springframework.beans.PropertyBatchUpdateException;
nested PropertyAccessExceptions (1) are:PropertyAccessException 1: org.springframework.beans.MethodInvocationException:
Property 'dataSource' threw exception;
nested exception is java.lang.NoClassDefFoundError:
org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy
这个错误是真的离谱 忘记导jdbc的包了 哈哈哈蠢死我
<!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.3.2</version>
</dependency>
导入之后就可以运行啦 !
3、
java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed
这个是网上大佬提出来的
需要在url后面添加一个allowPublicKeyRetrieval=true
4、(还有问题是真的服了)
java.sql.SQLException: Access denied for user 'Administrator'@'localhost' (using password: YES)
修改一下Username的这个属性的名字就好了
具体的原因请参考
https://blog.csdn.net/qq_40147863/article/details/86498386
终于跑起来啦!不容易啊