我想使用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>
答案 0 :(得分:3)
似乎缺少对spring-data-oracle的依赖。试试这个:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-oracle</artifactId>
<version>1.2.1.RELEASE</version>
</dependency>
答案 1 :(得分:0)
在maven存储库中无法访问JDBC驱动程序。您需要从OTN
手动下载JDBC驱动程序使用以下命令在Maven上安装它。
mvn install:install-file -Dfile = / LIB / 12102 / ojdbc7.jar -DgroupId = com.oracle -DartifactId = ojdbc7 -Dversion = 12.1.0.1 -Dpackaging =罐子 -DgeneratePom =真
您可以在pom.xml中包含依赖项,如图所示。
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.1</version>
</dependency>