简体   繁体   中英

Add dependency in maven project for j2ee.jar

What is the maven dependency for j2ee.jar. I tried doing this way. But still its not working..

    <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>

  <repositories>
    <repository>
        <id>Java.Net</id>
        <url>http://download.java.net/maven/2/</url>
    </repository>
  </repositories>


  <dependencies>

  <!-- Javaee API -->
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
    </dependency>



  <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>

I am trying to configure this http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/doc/PoolingDriverExample ‌​.java?view=markup example in my maven project. So in that I have to add j2ee.jar into my classpath. But If I am adding by above in my pom.xml then I am getting some error as ConnectionFactory cannot be resolved to a type

Update-

<!-- Javaee API -->
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>6.0</version>
        <scope>runtime</scope>
    </dependency>

still I am getting the same error for ConnectionFactory cannot be resolved to a type..

The repo you specified does not provide that version:6.0

The repo you specified has http://download.java.net/maven/glassfish/javax/javaee/javaee/

  1. 5.0-SNAPSHOT/ 14-Feb-2008 15:04 1K
  2. 6.0-alpha-1/ 16-Apr-2008 17:36 1K
  3. 6.0-alpha-2-SNAPSHOT/ 23-Apr-2008 08:31 1K

You may want to use http://repo1.maven.org/maven2 which does provide the resource and version you specified.

Also, your scope should be "provided". Having a runtime scope tells maven that the dependency is needed for runtime but not compilation. You need the opposite. Your dependency is needed for compilation but not runtime because it's "provided" by the container. See http://maven.apache.org/pom.html for more details.

You can check for transitive dependencies using the maven dependency plugin. Just do an

  mvn dependency:tree

Hope this answers your question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM