简体   繁体   中英

Maven won't deploy on Sonatype Nexus Repository

[Links are replaced with [http] because StackOverflow does not allow more than 2 links for me...]

I have installed Apache Maven 3.2.3 ([http]maven.apache.org/download.cgi?Preferred= ftp://mirror.reverse.net/pub/apache/ ), and it has downloaded all core plugins.

Then I installed Sonatype Nenus OSS ([http]www.sonatype.org/nexus/go/) as a WAR application on my XAMPP tomcat server.

Everything is well set and works. My unique goal here is to test a deployment of a file from my local Maven to my Nexus repository.

Here is my POM file project:

<project xmlns="..."
     xmlns:xsi="..."
     xsi:schemaLocation="...">
<modelVersion>4.0.0</modelVersion>

<groupId>groupA</groupId>
<artifactId>artifactA</artifactId>
<version>1.0.0</version>

<distributionManagement>
  <repository>
    <id>releases</id>
    <url>[http]localhost:8080/nexus-2.9.2-01/content/repositories/releases</url>
  </repository>
</distributionManagement>

</project>

And here is my Maven configuration file: settings.xml

<settings xmlns="..."
xmlns:xsi="..."
xsi:schemaLocation="...">

<servers>
  <server>
   <id>releases</id>
   <username>deployment</username>
   <password>deployment123</password>
  </server>
</servers>

The account provided is the default one and it works from the Nexus GUI. My Nexus repository "releases" is configured as following: [http]i.stack.imgur.com/Nh3dO.png

And when i use the following command:

   mvn deploy

Or the following:

   mvn deploy:deploy

Which are almost the same as far as I'm concerned... Maven tells me this: [http]i.stack.imgur.com/2vBNx.png

And the [Help 1] tells nothing but "see the plugin documentation". And the error message tells me that "The repository element is not specified in the POM file", but it actually is...

I really don't see what i am missing :/ Thanks for your help

Thank you all for your answers. I don't really have an idea why it works, but using these files works:

ArtifactA POM file:

<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>groupA</groupId>
    <artifactId>artifactA</artifactId>
    <version>1.2.4</version>

    <dependencyManagement>
        <dependencies>
        </dependencies>
    </dependencyManagement>

    <distributionManagement>
        <repository>
            <id>nexus</id>
            <name>Nexus Test Repository</name>
            <url>http://localhost:8080/nexus-2.9.2-01/content/repositories/releases</url>
        </repository>
    </distributionManagement>

</project>

ArtifactB POM file:

<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>groupA</groupId>
    <artifactId>artifactB</artifactId>
    <version>1.0.0</version>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>groupA</groupId>
                <artifactId>artifactA</artifactId>
                <version>1.2.4</version>
                <type>zip</type>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <distributionManagement>
        <repository>
            <id>nexus</id>
            <name>Nexus Test Repository</name>
            <url>http://localhost:8080/nexus-2.9.2-01/content/repositories/releases</url>
        </repository>
    </distributionManagement>

</project>

Maven settings file:

    <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd">

  <servers>
    <server>
      <id>nexus</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
  </servers>

  <mirrors>
    <mirror>
      <id>nexus</id>
      <name>Nexus Test Repository</name>
      <url>http://localhost:8080/nexus-2.9.2-01/content/repositories/releases</url>
      <mirrorOf>*,!central</mirrorOf>
    </mirror>
  </mirrors>

</settings>

Deployment script:

mvn deploy:deploy-file \
-Dfile=artifactA_package.zip \
-Dpackaging=zip \
-DpomFile=pomA1.2.4.xml \
-Durl=http://localhost:8080/nexus-2.9.2-01/content/repositories/releases \
-DrepositoryId=nexus

mvn deploy:deploy-file \
-Dfile=artifactB_package.zip \
-Dpackaging=zip \
-DpomFile=pomB1.0.0.xml \
-Durl=http://localhost:8080/nexus-2.9.2-01/content/repositories/releases \
-DrepositoryId=nexus

Hope it will help the next one :)

I use wagon-webdav-jackrabbit pluging in combination with something like your configurations. It enables Maven to deploy artifacts and files to WebDAV enabled servers.

http://maven.apache.org/wagon/wagon-providers/wagon-webdav-jackrabbit/

Paste this in your pom.xml

<build>
        <extensions>
            <extension>
                <groupId>org.apache.maven.wagon</groupId>
                <artifactId>wagon-webdav-jackrabbit</artifactId>
                <version>2.4</version>
            </extension>
        </extensions>
    </build>

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