ClassNotFoundException:org.springframework.jdbc.datasource.DriverManagerDataSource [英] ClassNotFoundException: org.springframework.jdbc.datasource.DriverManagerDataSource

查看:2074
本文介绍了ClassNotFoundException:org.springframework.jdbc.datasource.DriverManagerDataSource的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试做一些基本的数据库操作。我正在使用STS 3.2.0,Apache Tomcat 7.

I was trying to do some basic database operations. I'm using STS 3.2.0, Apache Tomcat 7.

我的dispatcher-servlet.xml包括:

My dispatcher-servlet.xml includes:

<bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://localhost:3306/mydb" />
        <property name="username" value="root" />
        <property name="password" value="root" />
    </bean>

Apache Tomcat失败了数以千计的异常,从这一个开始:

Apache Tomcat fails miserably with thousands of exceptions, starting with this one :

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.jdbc.datasource.DriverManagerDataSource] for bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.jdbc.datasource.DriverManagerDataSource
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.jdbc.datasource.DriverManagerDataSource] for bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.jdbc.datasource.DriverManagerDataSource

编辑1: 我还下载了jar的3.0.3.RELEASE版本,它仍然是一样的。

EDIT 1: I also downloaded 3.0.3.RELEASE version of the jar, and its still the same.

最终编辑看来,你也应该手动将你的外部jar文件添加到你的部署目录中(如果你不使用任何为你这样做的扩展名),那么

FINAL EDIT It seems, you should add your external jar files manually to your deployment directory as well (well if you don't use any extension that'd do that for you)

推荐答案

尝试添加到POM.xml:

Try to add to POM.xml:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jdbc</artifactId>
    <version>3.0.3.RELEASE</version>
</dependency>

这篇关于ClassNotFoundException:org.springframework.jdbc.datasource.DriverManagerDataSource的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆