我查看了StackOverflow上可以找到的所有内容,但我找不到答案.我刚刚建立了一台新机器,我有一些项目可以在以前的安装中编译和构建.但我的新机器不会.一切似乎正在构建正确(没有构建错误,正确包含依赖项),但我的项目中的实际类文件(我写的代码)不包含在jar中.然后我创建了一个简单的helloWorld项目,其中包含一些最小的POM文件,可以看到问题仍然存在.我从命令行进行构建,将eclipse从等式中取出.
班级代码
package com.zoverge.utils;
public class HelloWorld {
/**
* @param args
*/
public static void main(String[] args) {
String message = args[0];
System.out.println(message);
}
}
Run Code Online (Sandbox Code Playgroud)
我的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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.zoverge.utils</groupId>
<artifactId>helloworld</artifactId>
<packaging>jar</packaging>
<version>1.0</version>
<name>Hello World</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.java.version>1.6</project.build.java.version>
<org.apache.maven.plugins.maven-compiler-plugin.version>2.5.1</org.apache.maven.plugins.maven-compiler-plugin.version>
</properties>
<build>
<plugins>
<!-- Maven will compile our source java classes using the "project.build.java.version"
specified -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${org.apache.maven.plugins.maven-compiler-plugin.version}</version>
<configuration>
<source>${project.build.java.version}</source>
<target>${project.build.java.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.zoverge.utils.HelloWorld</mainClass>
</manifest>
</archive> …Run Code Online (Sandbox Code Playgroud)