[链接替换为[http],因为StackOverflow不允许超过2个链接...]
我已安装Apache Maven 3.2.3([http] maven.apache.org/download.cgi?Preferred = ftp://mirror.reverse.net/pub/apache/),并已下载所有核心插件。
然后我在我的XAMPP tomcat服务器上安装了Sonatype Nenus OSS([http] www.sonatype.org/nexus/go/)作为WAR应用程序。
一切都很好,有效。 我的独特目标是测试从我的本地Maven到Nexus存储库的文件部署。
这是我的POM文件项目:
<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>
这是我的Maven配置文件:settings.xml
<settings xmlns="..."
xmlns:xsi="..."
xsi:schemaLocation="...">
<servers>
<server>
<id>releases</id>
<username>deployment</username>
<password>deployment123</password>
</server>
</servers>
提供的帐户是默认帐户,可以在Nexus GUI中使用。 我的Nexus存储库&#34;发布&#34;配置如下: [HTTP] i.stack.imgur.com/Nh3dO.png
当我使用以下命令时:
mvn deploy
或以下内容:
mvn deploy:deploy
就我而言,这几乎是一样的...... Maven告诉我这个: [HTTP] i.stack.imgur.com/2vBNx.png
[帮助1]除了&#34之外什么都没说,请参阅插件文档&#34;。并且错误消息告诉我&#34;未在POM文件&#34;中指定存储库元素,但它实际上是......
我真的不知道自己错过了什么:/ 谢谢你的帮助
答案 0 :(得分:1)
谢谢大家的回答。我真的不知道它为什么会起作用,但是使用这些文件会起作用:
ArtifactA POM文件:
<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文件:
<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 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>
部署脚本:
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
希望它能帮助下一个:)
答案 1 :(得分:0)
我使用wagon-webdav-jackrabbit插件与你的配置相结合。它使Maven能够将工件和文件部署到启用WebDAV的服务器。
http://maven.apache.org/wagon/wagon-providers/wagon-webdav-jackrabbit/
将其粘贴到您的pom.xml
中<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-webdav-jackrabbit</artifactId>
<version>2.4</version>
</extension>
</extensions>
</build>