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