Java Maven的问题
当我想在我的项目中运行“mvn部署”时,我遇到以下错误:Java Maven的问题,java,maven,Java,Maven,当我想在我的项目中运行“mvn部署”时,我遇到以下错误: [INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ JImp --- [INFO] Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.jar [INFO] Downloaded: https://repo.
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ JImp ---
[INFO] Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.jar
[INFO] Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/1.5.6/plexus-utils-1.5.6.jar (245 KB at 188.8 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.973 s
[INFO] Finished at: 2014-12-16T10:35:39+01:00
[INFO] Final Memory: 24M/226M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project JImp: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
我的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>JImp</groupId>
<artifactId>JImp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.6.0</version>
</dependency>
<dependency>
....
</dependency>
</dependencies>
</project>
然后执行我的jar
java -cp target\JImp-0.0.1-SNAPSHOT.jar de.my.path.JImp
他抛出了一个ClassNotFoundException,因为他找不到我自己库的类。。但此库已添加到本地存储库和我的POM文件中的Dependency..:/
也许你能帮我
我非常感谢你的帮助 对于
mvn部署问题
您需要在pom.xml中提供要部署arfifact的存储库地址,如下所示
<distributionManagement>
<repository>
<id>mycompany-repository</id>
<name>MyCompany Repository</name>
<url>your repository url</url>
</repository>
</distributionManagement>
我发现:“Maven将首先尝试使用指定工件的本地副本。如果本地存储库中不存在该工件,它将尝试从远程存储库下载”()当我想使用mvn deploy时,为什么我必须定义一个存储库?调用mvn包就足够了,还是我必须通过调用mvn deploymvn deploy
命令来运行整个默认生命周期(验证、编译、测试、打包、集成测试、验证、安装、部署)来将您的工件上传到远程存储库。如果您只想添加到本地存储库中,那么mvn安装
就可以了。对于第二个问题,它作为生命周期运行,所以当您在生命周期阶段执行时,比如说包
,在它自动执行之前的所有阶段。非常感谢您的帮助!!!关于我的第二个问题:默认情况下应该调用哪个阶段?我知道,这取决于我想要什么,但是“集成测试”和“验证”阶段对查找错误或类似的东西有用吗?我认为我不需要“安装”和“部署”阶段,因为我不在其他项目(本地和远程存储库)中使用我的工件
<distributionManagement>
<repository>
<id>mycompany-repository</id>
<name>MyCompany Repository</name>
<url>your repository url</url>
</repository>
</distributionManagement>
mvn exec:java -Dexec.mainClass="de.my.path.JImp"