我有一个maven项目,我在Intellij IDEA中导入它。一切正常,除非我部署maven项目控制台时显示以下错误
[错误]无法在项目多站点上执行目标org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy(default-deploy):部署失败:未在分配管理元素中的POM中指定存储库元素或者在-DaltDeploymentRepository = id :: layout :: url参数 - > [帮助1]
这是我的pom.xml文件代码
<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>multisite</groupId>
<artifactId>multisite</artifactId>
<version>1</version>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.2</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.5</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.14.4</version>
</dependency>
</dependencies>
有人可以告诉我如何在我的项目中指定maven存储库元素路径,还是pom.xml文件中还缺少其他任何内容?
@ItachiUchiha:这是我现在进入控制台的完整错误,
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building multisite 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- exec-maven-plugin:1.4.0:java (default-cli) @ multisite ---
[WARNING]
java.lang.ClassNotFoundException: src/multisite/Main
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:281)
at java.lang.Thread.run(Thread.java:745)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.144 s
[INFO] Finished at: 2015-10-30T16:57:08+05:00
[INFO] Final Memory: 10M/153M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java (d
efault-cli) on project multisite: An exception occured while executing the Java
class. src/multisite/Main -> [Help 1]
答案 0 :(得分:1)
当您尝试使用mvn deploy
时,您需要指定部署位置。
deploy
命令执行以下操作:
将最终包复制到远程存储库,以便与其他开发人员和项目共享。
可以使用distributionManagement
标签在pom中指定,如下所示:
<distributionManagement>
<repository>
<id>nexus-site</id>
<url>http://central_nexus/server</url>
</repository>
</distributionManagement>
有关详细信息,请浏览Distribution Management上的文档。
答案 1 :(得分:1)
您尚未指定正确的<distributionManagement/>
部分。
您在pom.xml
:
<distributionManagement>
<repository>
<id>releases</id>
<url>https://repository-server/releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>https://repository-server/snapshots</url>
</snapshotRepository>
</distributionManagement>
除此之外,在~/.m2/settings.xml
文件中,您还需要包含以下部分:
<servers>
<server>
<id>releases</id>
<username>username-goes-here</username>
<password>password-goes-here</password>
</server>
<server>
<id>releases</id>
<username>username-goes-here</username>
<password>password-goes-here</password>
</server>
请注意,<ìd/>
部分必须相互匹配,因为它们是映射。