Unable to access parent project library (jar) in child module - Maven

I have a project called Parent. His type is POM. There is a library ( ojdbc6.jar ) that is not available in the open repository, so I access it through <SystemPath> , as you can see below pom.xml :

 <project> <modelVersion>4.0.0</modelVersion> <groupId>com.Parent</groupId> <artifactId>Parent</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>pom</packaging> <modules> <module>childModule</module> </modules> <dependencies> <dependency> <groupId>com.oracle</groupId> <artifactId>ojdbc</artifactId> <version>6</version> <scope>system</scope> <systemPath>${basedir}/lib/ojdbc6.jar</systemPath> </dependency> </dependencies> <repositories> <repository> <id>in-project</id> <name>In Project Repo</name> <url>file://${basedir}/lib</url> </repository> </repositories> 

Now the names of the child projects Child-Module1 and Child-Module2 use this library ( ojdbc6.jar ). POM is listed below:

 <project> <modelVersion>4.0.0</modelVersion> <artifactId>testApp</artifactId> <version>1.14.5.1-SNAPSHOT</version> <packaging>war</packaging> <name>APP1</name> <description>Application</description> <parent> <groupId>com.Parent</groupId> <artifactId>Parent</artifactId> <version>0.0.1-SNAPSHOT</version> </parent> </project> 

When I build using Maven, this gives me an error:

 Description Resource Path Location Type The container 'Maven Dependencies' references non existing library 'C:\Users\ABCCOMPUTER_NAME\.m2\repository\com\oracle\ojdbc\6\ojdbc-6.jar' testApp Build path Problem. 

Why does it look in the local repository? This only happens when the parent project contains a library ( jar ) that contains the system path. This does not happen when the access path library ( jar ) in the same project as the parent, referencing ojdbc6.jar , is good there.

+6
source share
2 answers

I solved the problem by updating systemPath in the parent pom.xml, as shown below:

  <systemPath>${main.basedir}/lib/ojdbc6.jar</systemPath> 

and then adding the main.basedir property to the parent pom.xml and repository

 <properties> <main.basedir>${project.basedir}</main.basedir> </properties> <repositories> <repository> <id>in-project</id> <name>In Project Repo</name> <url>file://${main.basedir}/lib</url> </repository> </repositories> 

then adding property elements and repositories in the child module ("/ .." is added when the folder of the child module is in the parent folder, so go up one directory and then leave the absolute path to the parent lib folder should be generated as expected)

  <properties> <main.basedir>${project.basedir}/..</main.basedir> </properties> <repositories> <repository> <id>in-project</id> <name>In Project Repo</name> <url>file://${main.basedir}/lib</url> </repository> </repositories> 
+4
source

From: fooobar.com/questions/8850 / ...

Finally, declare it like any other dependency (but without the system scope):

 <dependency> <groupId>your.group.id</groupId> <artifactId>3rdparty</artifactId> <version>XYZ</version> </dependency> 
0
source

All Articles