java - Oracle 池数据源 - 无法找到 Spring NamespaceHandler

标签 java spring oracle jdbc oracle11g

我想使用 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>

最佳答案

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

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

关于java - Oracle 池数据源 - 无法找到 Spring NamespaceHandler,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31861843/

相关文章:

java - 如何使用 SHA-256 对字符串进行哈希处理

java - 在 for 循环中添加到 HashMap 时跳过多个字符

java - 如何让任务x在计划任务y之后运行

java - Gradle-编译多个项目,但未找到共享的项目类

sql - 开始使用 Oracle Express 版?

java - 自定义 Log4j2 包装器和输出

java - 下载后 jar 文件损坏

java - 在 ServletContextListener 使用 web.xml 中的文件路径之前设置 JUnit 测试的系统属性

Oracle 和 Hibernate 之间的 Java 数据类型不匹配

java - HTTP 状态 500 - servlet appServlet 的 Servlet.init() 在 spring MVC 中抛出异常