简体   繁体   中英

Maven Does Not Recognize Jar In Local Repository

I have jars that are committed in the source repository that I need to use as dependencies in a maven project. After researching, adding a project specific, local repository seems to be the cleanest way. Note, this repository will be specific to this project and different from the local repo on my machine under the .m2 directory. The pom is type war and I have defined the repository like this below the description:

<repositories>
    <repository>
       <id>project-repo</id>
       <name>project-repo</name>
       <url>file://${basedir}/WebContent/WEB-INF/lib</url>
    </repository>
 </repositories>

Within the lib directory is this path to the jar an no other files:

com/mycompany/stuff/my-artifact/1.0.0/my-artifact-1.0.0.jar.

This dependency is in the same pom.xml:

<dependency>
    <groupId>com.mycompany.stuff</groupId>
    <artifactId>my-artifact</artifactId>
    <version>1.0.0</version>
</dependency>

If I look at the Effective POM, I see project-repo listed with the correct path under the two repositories defined in my user settings.xml. So it is listed, but it is listed last. When I execute a mvn clean package, it fails with the error: Could not find artifact in "name-of-repo" from settings.xml. It doesn't appear to be checking the repository that I specified in the pom. Among other posts, I am using this: How to include local jar files in Maven project as a reference and the maven documentation found here: https://maven.apache.org/guides/mini/guide-multiple-repositories.html and here: https://maven.apache.org/guides/introduction/introduction-to-repositories.html . Any ideas why it appear to only be checking the repos defined in the settings.xml?

The build is checking for dependencies in the project repo now. I'm not sure why this matters, but once I shortened the repo path to this, it started working.

<url>file://${basedir}/localRepo</url>

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