我正在尝试运行此示例http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/doc/PoolingDataSourceExample.java?view=markup但不知何故我无法做到。我想在一个 maven 项目中运行这个例子,而且我也是第一次在 maven 项目上工作。而且我不知道该怎么做。就像在那个例子中一样,它清楚地表明——
To compile this example, you'll want:
* commons-pool-1.5.4.jar
* commons-dbcp-1.2.2.jar
* j2ee.jar (for the javax.sql classes)
in your classpath.
To run this example, you'll want:
* commons-pool-1.5.6.jar
* commons-dbcp-1.3.jar (JDK 1.4-1.5) or commons-dbcp-1.4 (JDK 1.6+)
* j2ee.jar (for the javax.sql classes)
* the classes for your (underlying) JDBC driver
in your classpath.
因此,在阅读了各种文章后,我尝试将所有这些依赖项添加到我的 pom.xml 文件中。但是我仍然遇到错误,例如-
ConnectionFactory cannot be resolved to a type
GenericObjectPool cannot be resolved to a type
ObjectPool cannot be resolved to a type
PoolableConnectionFactory cannot be resolved to a type
PoolableConnectionFactory cannot be resolved to a type
PoolingDataSource cannot be resolved to a type
PoolingDataSource cannot be resolved to a type
这是我的 pom.xml 文件。我的 pom.xml 文件中是否缺少任何内容。任何建议将不胜感激,因为这是我第一次使用 Maven 项目。
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.datasource.pooling</groupId>
<artifactId>datasource.pooling</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>com.datasource.pooling</name>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0</version>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>1.5.4</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.2.2</version>
</dependency>
<!--
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<version>1.5.6</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.3</version>
</dependency>
-->
</dependencies>
</project>
添加 j2ee.jar 文件的依赖项是什么。