Spring Beans:DriverManagerDataSource转换为sun.jdbc.odbc.ee.DataSource

时间:2014-08-20 16:35:02

标签: java spring postgresql spring-mvc jdbc

我有一个Spring MVC项目,我使用NamedParameterJdbcTemplate连接到postgres database

当我尝试启动我的应用程序时,我得到一个例外:

Cannot convert value of type 
[org.springframework.jdbc.datasource.DriverManagerDataSource] 
to required type [sun.jdbc.odbc.ee.DataSource] for 
property 'dataSource': no matching editors or conversion strategy found

我的dataSource bean看起来像这样:

<bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="org.postgresql.Driver" />
    <property name="url" value="jdbc:postgresql://localhost:5432/********" />
    <property name="username" value="postgres" />
    <property name="password" value="********" />
</bean>

我以前用NamedParameterJdbcTemplate连接到postgres。我错过了一个依赖项,使这种转换成为可能,或者是什么问题?

1 个答案:

答案 0 :(得分:3)

作为例外,itsel显示它期待sun.jdbc.odbc.ee.DataSource

并找到org.springframework.jdbc.datasource.DriverManagerDataSource

这意味着您在使用DataSource类时无法导入错误,请确保从javax.sql.DataSource导入