【问题标题】:Oracle Pooling DataSource - Unable to locate Spring NamespaceHandlerOracle Pooling DataSource - 无法找到 Spring NamespaceHandler
【发布时间】:2015-10-29 23:03:27
【问题描述】:

我想使用 Spring 实现 Oracle Pooling DataSource,如下所述: http://docs.spring.io/spring-data/jdbc/docs/current/reference/html/orcl.datasource.html

但是,我遇到了这个问题:

Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/data/orcl]
Offending resource: class path resource [applicationContext.xml]

据我了解,这个问题是由于 Spring 无法找到 Oracle JDBC Driver 造成的。但是,驱动程序在我的类路径中;所以,我不知道是什么导致了这个问题。

applicationContext.xml

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

<orcl:pooling-datasource
    id="dataSource"
    url="jdbc:oracle:thin:@//abc.ca:1527/abc_default.abc.ca"
    username="abc"
    password="abc"/>

pom.xml

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

    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.2</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.retry</groupId>
        <artifactId>spring-retry</artifactId>
        <version>1.1.2.RELEASE</version>
    </dependency>

【问题讨论】:

  • 你有没有弄明白这个?我也面临同样的问题。
  • 我放弃了。我在使用 Oracle 池数据源时遇到了太多问题;因此,我按照此处所述移至 C3P0:stackoverflow.com/questions/33553532/…

标签: java spring oracle jdbc oracle11g


【解决方案1】:

似乎缺少对 spring-data-oracle 的依赖。试试这个:

<dependency>
  <groupId>org.springframework.data</groupId>
  <artifactId>spring-data-oracle</artifactId>
  <version>1.2.1.RELEASE</version>
</dependency>

【讨论】:

    【解决方案2】:

    在 maven 存储库上将无法访问 JDBC 驱动程序。您需要从OTN手动下载 JDBC 驱动程序

    使用以下命令在 Maven 上安装它。

    mvn install:install-file -Dfile=/lib/12102/ojdbc7.jar -DgroupId=com.oracle -DartifactId=ojdbc7 -版本=12.1.0.1 -D包装=罐子 -DgeneratePom=true

    您可以在 pom.xml 中包含依赖项,如图所示。

    <dependency>
          <groupId>com.oracle</groupId>
          <artifactId>ojdbc7</artifactId>
          <version>12.1.0.1</version>
        </dependency>
    

    【讨论】:

    • JDBC 驱动程序已使用类似方法安装在我的存储库中。然而,这给我带来了一个新问题。我第二次猜测我是否下载了正确的驱动程序。将,重新下载并再次测试。谢谢
    猜你喜欢
    • 1970-01-01
    • 2013-02-13
    • 2011-03-21
    • 2017-05-15
    • 2011-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-01
    相关资源
    最近更新 更多