Question

Je veux ajouter l'oracle pilote jdbc à mon projet en tant que dépendance (champ d'exécution) - ojdbc14. Dans le site MVNrepository la dépendance à mettre dans le POM est:

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc14</artifactId>
    <version>10.2.0.3.0</version>
</dependency>

Bien sûr, ce does't travail car il est pas dans le référentiel central utilisé par Maven. 2 questions:

  1. Comment puis-je trouver un dépôt (le cas échéant) qui contient cet artefact?

  2. Comment puis-je ajouter pour que Maven va l'utiliser?

Était-ce utile?

La solution

Comment puis-je trouver un dépôt (le cas échéant) qui contient cet artefact?

Malheureusement, en raison de la licence binaire il n'y a pas de dépôt public avec le JAR du pilote Oracle. Cela se produit avec de nombreuses dépendances, mais ne sont pas la faute de Maven. Si vous arrivez à trouver un dépôt public contenant le JAR, vous pouvez être sûr que ce soit illégal.

Comment puis-je ajouter pour que Maven va l'utiliser?

Quelques jars qui ne peuvent être ajoutés pour des raisons de licence ont une pom entrée dans la repo central Maven. Il suffit de vérifier, il contient l'information Maven préférée du vendeur:

<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.3.0</version>

... et l'URL pour télécharger le fichier qui dans ce cas est http://www.oracle.com/technology/software/tech /java/sqlj_jdbc/index.html .

Une fois que vous avez téléchargé le JAR simplement l'ajouter à votre référentiel d'ordinateur avec (note I tiré groupId, artifactId et la version du POM):

mvn install:install-file -DgroupId=com.oracle -DartifactId=ojdbc14 \
     -Dversion=10.2.0.3.0 -Dpackaging=jar -Dfile=ojdbc.jar -DgeneratePom=true

Le dernier paramètre pour générer un POM vous permettra d'économiser des avertissements pom.xml

Si votre équipe a un dépôt local ce guide pourrait être utile de télécharger le fichier JAR il.

Autres conseils

Pour une raison quelconque, je ne pouvais pas obtenir l'une des solutions ci-dessus pour travailler. (Ne peut toujours pas.)

Ce que j'a plutôt d'inclure le pot dans mon projet (Blech), puis créer une dépendance « système » pour ce qui indique le chemin du pot. Il est sans doute pas la bonne façon de le faire, mais cela fonctionne. Et il élimine le besoin pour les autres développeurs de l'équipe (ou le gars mise en place du serveur de build) pour mettre le pot dans leurs dépôts locaux.

UPDATE : Cette solution fonctionne pour moi quand je lance outils Hibernate. Il ne semble pas fonctionner pour la construction du fichier WAR, cependant. Il ne comprend pas le fichier ojdbc6.jar dans le fichier cible WAR.

1) Créez un répertoire appelé "lib" dans la racine de votre projet.

2) Copiez le fichier ojdbc6.jar il (quel que soit le pot est appelé.)

3) Créer une dépendance qui ressemble à quelque chose comme ceci:

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc</artifactId>
    <version>14</version>
    <scope>system</scope>
    <systemPath>${basedir}/lib/ojdbc6.jar</systemPath> <!-- must match file name -->
</dependency>

laid, mais fonctionne pour moi.

Pour inclure les fichiers dans le fichier de guerre ajoutez ce qui suit à votre pom

<build>
    <finalName>MyAppName</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <webResources>
                    <resource>
                        <directory>${basedir}/src/main/java</directory>
                        <targetPath>WEB-INF/classes</targetPath>
                        <includes>
                            <include>**/*.properties</include>
                            <include>**/*.xml</include>
                            <include>**/*.css</include>
                            <include>**/*.html</include>
                        </includes>
                    </resource>
                    <resource>
                        <directory>${basedir}/lib</directory>
                        <targetPath>WEB-INF/lib</targetPath>
                        <includes>
                            <include>**/*.jar</include>
                        </includes>
                    </resource>
                </webResources>
            </configuration>
        </plugin>

        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>

Télécharger le pot et placez-le dans votre projet src/lib. Maintenant, vous pouvez utiliser le plug-in d'installation de Maven.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-install-plugin</artifactId>
    <version>2.3.1</version>
    <executions>
        <execution>
            <id>install-oracle-jdbc</id>
            <goals>
                <goal>install-file</goal>
            </goals>
            <phase>clean</phase>
            <configuration>
                <groupId>com.oracle</groupId>
                <artifactId>ojdbc6</artifactId>
                <version>11.2.0</version>
                <packaging>jar</packaging>
                <generatePom>true</generatePom>
                <createChecksum>true</createChecksum>
                <file>${project.basedir}/src/lib/ojdbc6.jar</file>
            </configuration>
        </execution>
    </executions>
</plugin>

Maintenant, il suffit d'exécuter une fois l'mvn clean oracle lib est installé dans votre repository local.

Oracle est maintenant un expose repository à maven.oracle.com Cependant, vous devez être authentifié.

Voir https://blogs.oracle.com/WebLogicServer/entry/weblogic_server_and_the_oracle

D'après les commentaires du billet de blog le conducteur ojdbc devrait être disponible aux coordonnées suivantes:

<groupId>com.oracle.weblogic</groupId>
 <artifactId>ojdbc7</artifactId>
 <version>12.1.3-0-0</version>
 <packaging>jar</packaging>

Essayez avec:

<repositories>
    <!-- Repository for ORACLE ojdbc6. -->
    <repository>
        <id>codelds</id>
        <url>https://code.lds.org/nexus/content/groups/main-repo</url>
    </repository>
</repositories>
<dependencies> 
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0.3</version>
    </dependency>
</dependencies> 

Le pilote JDBC Oracle est maintenant disponible dans le référentiel Maven Oracle (pas dans le centre).

<dependency>
    <groupId>com.oracle.jdbc</groupId>
    <artifactId>ojdbc7</artifactId>
    <version>12.1.0.2</version>
</dependency>

L'Oracle Maven référentiel nécessite un enregistrement utilisateur. Les instructions se trouvent dans:

https://blogs.oracle.com/dev2dev/get-oracle-jdbc-drivers-and-ucp-from-oracle-maven-repository-without-ides

1. How do I find a repository (if any) that contains this artifact?

As DavidS has commented the line I quoted at the time I answered is no longer present in the current (at the time I'm writing now) OTN License Agreement agreement I linked. Consider this answer only for older version of the artifact, as the 10.2.0.3.0 and the like.

All Oracle Database JDBC Drivers are distribuited under the OTN License Agreement.

If you read the OTN License Agreement you find this license term:

You may not:
...
- distribute the programs unless accompanied with your applications;
...

so that's why you can't find the driver's jar in any public Maven Repository, because it would be distributed alone, and if it happened it would be a license violation.

Adding the dependency:

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc14</artifactId>
    <version>10.2.0.3.0</version>
</dependency>

(or any later version) make Maven downloads the ojdbc14-10.2.0.3.0.pom only, and in that pom you can read:

...
<licenses>
    <license>
        <name>Oracle Technology Network Development and Distribution License Terms</name>
        <url>http://www.oracle.com/technology/software/htdocs/distlic.html</url>
    </license>
</licenses>
...

which informs you about the OTN License.

2. How do I add it so that Maven will use it?

In order to make the above dependency works I agree with victor hugo who were suggesting you here to manually install the jar into your local Maven repository (the .m2 directory) by running:

mvn install:install-file -Dfile={Path_to_your_ojdbc.jar} -DgroupId=com.oracle 
-DartifactId=ojdbc -Dversion=10.2.0.3.0 -Dpackaging=jar

but I want to add that the license term above doesn't limit only where you can't find the JDBC jar, but it limits where you install it too!

In fact your local Maven repository must be private and not shared because if it was shared it would be a kind of distribution in which the jar is distributed alone, even if to a little group of people into your local area network, and this represent a OTN License Agreement violation.

Moreover I think you should avoid installing the JDBC jar in your corporation repository manager (such as Artifactory or Nexus) as a single artifact because if it was installed it would be still distributed alone, even if to people in your organization only, and this represents a OTN License Agreement violation.

You can use Nexus to manage 3rd party dependencies as well as dependencies in standard maven repositories.

Up to now, its not possible to use maven repositories. I'm using ivy as dependency management tool, but also use maven2' s ibiblio repositories. And this is working for ivy:

<dependency org="oracle" name="ojdbc14" rev="10.2.0.2" conf="*->default"/>

Maven2' s dependency could be something like that:

<dependency> 
    <groupId>oracle</groupId> 
    <artifactId>ojdbc14</artifactId> 
    <version>10.2.0.2</version> 
</dependency>

Notice that i define http://download.java.net/maven/2/ and http://mirrors.ibiblio.org/pub/mirrors/maven/mule/dependencies/maven2/[organisation]/[module]/[revision]/[artifact]-[revision].[ext] as external maven2 repos on my ivy settings.

Some Oracle Products support publishing maven artifacts to a local repository. The products have a plugin/maven directory which contains descriptions where to find those artifacts and where to store them. There is a Plugin from Oracle which will actually do the upload.

See: http://docs.oracle.com/middleware/1212/core/MAVEN/config_maven.htm

One of the products which may ship OJDBC in this way is the WLS, it uses however quite strange coordinates:

<groupId>com.oracle.weblogic</groupId>
<artifactId>ojdbc6</artifactId>
<version>12.1.2-0-0</version>

I ship opensource under LGPLv2 and even after several email conversations with Oracle they were unclear whether I was allowed to ship their binary JDBC driver with my distribution. The issue related to whether my license was compatible with their OTN terms so they suggested I was not permitted to ship the driver. Presumably related to this part

(b) to distribute the programs with applications you have developed to your customers provided that each such licensee agrees to license terms consistent with the terms of this Agreement

So even if you manage to publish the driver legally in your exclusive/local maven repository there is still the restriction on what you are permitted to do with that artifact. Seems absurd that even if I ship their driver in binary form along with the full OTN license file I still can't use it and must force my users to manually download the Oracle driver and drop into my library path before they can use my software.

There is one repo that provides the jar. In SBT add a resolver similar to this: "oracle driver repo" at "http://dist.codehaus.org/mule/dependencies/maven2"

and a dependency: "oracle" % "ojdbc14" % "10.2.0.2"

You can do the same with maven. pom.xml and jar are available (http://dist.codehaus.org/mule/dependencies/maven2/oracle/ojdbc14/10.2.0.2/).

If you are using Netbeans, goto Dependencies and manually install artifact. Locate your downloaded .jar file and its done. clean build will solve any issues.

You can find a Github simple sample project for use a Oracle JDBC Driver on Maven Project here.

You can find all explication for your continous integration + a sample and run on Travis-CI.

DEMO

For dependency

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc7</artifactId>
    <version>12.1.0.2</version>
</dependency>

Try

<repository>
    <id>mvnrepository</id>
    <url>http://nexus.saas.hand-china.com/content/repositories/rdc</url>
</repository>

SOLVED

  • Please do following settings to resolve the error

This repository needs to be enable for finding Oracle 10.0.3.0 dependecies (this setting needs to be done in Buildconfig.groovy grails.project.dependency.resolver = "ivy" // or ivy

Also use following setting for compile time Oracle driver download

runtime "com.oracle:ojdbc:10.2.0.3.0"

This should solve your issue for not finding the Oracle driver for grails application


Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top