Maven 创建空的 jar 文件

use*_*212 3 java maven

我正在尝试使用 maven 创建一个 jar 文件,但生成的 jar 是空的,并且只包含 META-INF 文件夹。它不包含类。

这是我的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>com.project</groupId>
    <artifactId>my-commons</artifactId>
    <version>1.0</version>
    <name>my-commons</name>
    <properties>
        <java-version>1.7</java-version>
    </properties>

    <dependencies>

    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
Run Code Online (Sandbox Code Playgroud)

怎么了?

use*_*253 6

Maven 项目的默认文件层次结构如下所示:

来源/
    主要的/
         爪哇/
              com/
                  我的公司/
                            主程序

可能有 test/... 就在 main/ 旁边。您也可以使用 <sourceDirectory> 标记(<build> 标记的子项)配置源目录。有关更多示例,请参阅https://maven.apache.org/guides/introduction/introduction-to-the-pom.html