Caused by: java.sql.SQLException: No suitable driver found for $(jdbc.url)

在配置spring基于纯注解配置的时候遇到一个报错:Caused by: java.sql.SQLException: No suitable driver found for $(jdbc.url)

Caused by: java.sql.SQLException: No suitable driver found for $(jdbc.url)
    at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:702)
    at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:189)
    at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:154)
    at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:145)
    at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:205)
    at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:169)
    at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:262)
    ... 38 more

网上查询这个错误导致的原因:
一是:连接URL格式出现了问题
二是:驱动字符串出错(com.mysql.jdbc.Driver)
三是Classpath中没有加入合适的mysql_jdbc驱动

检查了一下觉得没什么错误,于是打了断点看了看

13543313-3b8bf3b3b3b49057.png
可以看到driver是有值的,但是到url就无法识别了

我是这样定义的,仔细一看,能够解析出来的driver EL表达式是正确的,其他三个因为复制粘贴的原因没有做仔细检查,全部格式错误


Caused by: java.sql.SQLException: No suitable driver found for $(jdbc.url)_第1张图片
spring的El表达式错误

正确的El表达式 @Value("${driver}")

${"xxxxxx"}${"xxxxxx"}${"xxxxxx"}${"xxxxxx"}${"xxxxxx"}${"xxxxxx"}${"xxxxxx"}${"xxxxxx"}${"xxxxxx"}

你可能感兴趣的:(Caused by: java.sql.SQLException: No suitable driver found for $(jdbc.url))