Spring JDBC无法加载JDBC驱动程序类[oracle.jdbc.driver.OracleDriver] [英] Spring JDBC Could not load JDBC driver class [oracle.jdbc.driver.OracleDriver]

查看:830
本文介绍了Spring JDBC无法加载JDBC驱动程序类[oracle.jdbc.driver.OracleDriver]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人可以帮助我.当我尝试使用Spring JDBC编写代码时遇到了一个问题.当我运行服务器时,我收到了如标题中所述的消息.我有谷歌它,有人说你应该导入ojdbc.jar.但是,我已经导入了它.这是我的代码:

I wonder if any one could help me with this. I encountered an issue when I tried writing code with Spring JDBC. When I ran the server, I got the message like I mentioned in the title. I have google it and someone said that you should import ojdbc.jar. However, I have already imported it. Here comes my code:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
    <property name="url" value="jdbc:oracle:thin:@192.168.0.13:1521/orcl" />
    <property name="username" value="Hibernate" />
    <property name="password" value="123456" />
    </bean>

</beans>

请建议我是否做错了什么.预先非常感谢.

Please kindly suggest if I have done something wrong. Many thanks in advance.

推荐答案

请确保已将 ojdbc.jar 添加到您的类路径中.如果需要,也可以通过打开 .classpath 文件并查找 ojdbc.jar 条目来仔细检查它.如果没有,请按照如下所述从Maven存储库中下载它:

Make sure that you have ojdbc.jar gets added into your class path. If you want, you can also double check it by opening .classpath file and look for ojdbc.jar entry. If you don't have it, download it from the the maven repo as mentioned below:

        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.3</version>
        </dependency>
.......

    <repositories>
        <repository>
            <id>codelds</id>
            <url>https://code.lds.org/nexus/content/groups/main-repo</url>
        </repository>
    </repositories>

这篇关于Spring JDBC无法加载JDBC驱动程序类[oracle.jdbc.driver.OracleDriver]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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