Maven的问题

时间:2014-12-16 10:01:13

标签: java maven

当我想在我的项目中运行“mvn deploy”时,我收到以下错误:

[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-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>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文件(如SWT,Log4j等,但也有自己的库)。但所有这些都被添加到我的本地存储库(我自己的库,我通过mvn install:install-file ..添加)和我的POM的依赖项。在Eclipse中我的项目“知道”所有导入,代码看起来很好,没有错误或类似的东西..

如果我只运行

mvn package

然后执行我的jar

java -cp target\JImp-0.0.1-SNAPSHOT.jar de.my.path.JImp

他抛出一个ClassNotFoundException,因为他找不到我自己的lib类。但是这个lib被添加到本地存储库和我的POM-File中的依赖..:/

也许你可以帮助我...... !!

非常感谢你的帮助!

1 个答案:

答案 0 :(得分:1)

代表mvn deploy问题

您需要提供存储库地址,以便在pom.xml中部署arfifact,如下所示

<distributionManagement>
  <repository>
    <id>mycompany-repository</id>
    <name>MyCompany Repository</name>
    <url>your repository url</url>
  </repository>
</distributionManagement>

要运行maven artifact jar,需要使用mvn exec命令,然后只包含类路径中pom.xml中提到的所有jar。见下面的例子

mvn exec:java -Dexec.mainClass="de.my.path.JImp"