【发布时间】:2014-05-21 17:50:30
【问题描述】:
我正在使用maven assembly plug in 来打包我的项目及其所有依赖项,这样我就可以运行一个简单的 java -jar myproject.jar 并能够运行该项目。但是,当我运行罐子时,它告诉我
Error: Could not find or load main class com.project.ServerStart
然后我解压了.jar文件,发现程序集不包含我的项目文件,太可笑了!
打包项目时,我收到此警告
[WARNING] Cannot include project artifact: Amjar:amjar:pom:0.2; it doesn't have an associated file or directory.
这是我的插件配置
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<finalName>amjar-${project.version}</finalName>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.project.ServerStart</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>assemble-all</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
我做错了什么?
【问题讨论】:
-
我没有工作,因为我已经按照答案配置了我的 pom.xml,但是仍然出现错误!
-
同样的错误?
-
您确定在类路径中有
com.project.ServerStart? -
你能再解释一下吗?你在类路径上是什么意思?我怎样才能确定呢?我正在使用 Ubuntu 13.04,您希望我将所有项目类添加到 $PATH 变量吗?
标签: java maven maven-assembly-plugin