0

I have just set up an Artifactory instance on my local machine and deployed a jar to the libs-release repository. I have used the "Set me up" feature within Artifactory to generate my .settings.xml in /home/.m2/. However when I declare the dependency in a projects pom.xml, it is unable to resolve.

.settings.xml

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <servers>
    <server>
      <username>username</username>
      <password>password</password>
      <id>central</id>
    </server>
    <server>
      <username>username</username>
      <password>password</password>
      <id>snapshots</id>
    </server>
  </servers>
  <profiles>
    <profile>
      <repositories>
        <repository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>libs-release</name>
          <url>http://localhost:8080/artifactory/libs-release</url>
        </repository>
        <repository>
          <snapshots />
          <id>snapshots</id>
          <name>libs-snapshot</name>
          <url>http://localhost:8080/artifactory/libs-snapshot</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>central</id>
          <name>plugins-release</name>
          <url>http://localhost:8080/artifactory/plugins-release</url>
        </pluginRepository>
        <pluginRepository>
          <snapshots />
          <id>snapshots</id>
          <name>plugins-snapshot</name>
          <url>http://localhost:8080/artifactory/plugins-snapshot</url>
        </pluginRepository>
      </pluginRepositories>
      <id>artifactory</id>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>artifactory</activeProfile>
  </activeProfiles>
</settings>

dependency declaration in project pom.xml

<dependency>
    <groupId>com.zeroalpha.struts</groupId>
    <artifactId>struts-el</artifactId>
    <version>1.3.8</version>
</dependency>

I have confirmed that the deployed resource is located at libs-release-local/com/zeroalpha/struts/struts-el/1.3.8/struts-el-1.3.8.jar

The error in Eclipse says Missing artifact com.zeroalpha.struts:struts-el:jar:1.3.8

I have tried moving the repositories element from the .settings.xml to my own projects pom.xml, but that doesn't work either. Please advise.

secondbreakfast
  • 4,194
  • 5
  • 47
  • 101
  • 1
    Your set-up looks ok. Does Eclipse uses the correct `settings.xml`? Go to "Window > Preference > Maven > User settings", and check if the settings used in the right one. – Tunaki Oct 10 '16 at 19:43
  • @Tunaki yes, it is pointing to the correct file – secondbreakfast Oct 10 '16 at 19:45
  • @Tunaki I just confirmed that it is at least trying to read it too, because if I delete everything in settings.xml and type gibberish, Eclipse shows an error in the Maven settings saying the file cannot be read. – secondbreakfast Oct 10 '16 at 20:05
  • 1
    Hmm so I just tried just like you with the "set me up" option and I don't have any error. I just copy pasted the generated settings. Be sure to click "Update Settings" in the "Window > Preference > Maven > User settings" (multiple times :)). Also, right-click on your Maven Project, and select "Maven > Update Project", tick "Force Update of snapshots/release" and OK. That should solve any issue, your Maven config is correct. – Tunaki Oct 10 '16 at 20:15
  • @Tunaki what did you do for username password? Artifactory generates some weird thing like `${security.getEscapedEncryptedPassword()!"*** Insert encrypted password here ***"}`. Do you use that? – secondbreakfast Oct 10 '16 at 20:18
  • 1
    To download things, you can remove the whole `` config. It isn't needed, that's only for authentication when uploading. But I set `admin` `password` which are the default. – Tunaki Oct 10 '16 at 20:19
  • @Tunaki yes! Update project with Force update of snapshots/release did the trick! you rock!!!!!! – secondbreakfast Oct 10 '16 at 20:21
  • 1
    Glad it worked! I found another question with this information, so I voted to mark this one as duplicate, feel free to accept it. – Tunaki Oct 10 '16 at 20:29

0 Answers0