在spring编写引用第三方bean时我遇到的问题
错误提示
Error creating bean with name ‘druidDataSource’ defined in class path resource [applicationContext.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
解决办法
检查自己的配置文件
<context:property-placeholder location="classpath:db.properties"></context:property-placeholder>
<!--引入第三方的bean(druid)-->
<bean id="druidDataSource" class="com.alibaba.druid.pool.DruidDataSource">
<property name="url" value="${jdbc.url}"/>
**<property name="driver" value="${jdbc.driver}"/>**
<property name="name" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>
</beans>
发现自己写的
**< property name=“driver” value=“${jdbc.driver}”/>**中的name里面的值写错了
在更改为driverClassName后,运行成功
< property name="driverClassName" value="${jdbc.driver}"/>