Maven:JAR 将为空 - 没有内容被标记为包含 [英] Maven: JAR will be empty - no content was marked for inclusion

查看:33
本文介绍了Maven:JAR 将为空 - 没有内容被标记为包含的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 maven 时遇到了一个小问题.当我运行命令 mvn package 时,我收到以下警告:

I have a minor problem with maven. When I run the command mvn package I get the following warning:

[警告] JAR 将为空 - 没有内容被标记为包含!

构建成功,但生成的 jar 文件如警告所示为空.

The build is successful but the produced jar-file is empty as the warning says.

这是为什么,我做错了什么?

Why is this and what am I doing wrong?

这是我的 pom.xml

Here is my pom.xml

<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>framework</groupId>
<artifactId>framework</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>framework</name>
<url>http://maven.apache.org</url>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    My dependencies
</dependencies>

<build>
    <directory>target</directory>
    <outputDirectory>target/classes</outputDirectory>
    <finalName>${project.artifactId}-${project.version}</finalName>
    <testOutputDirectory>target/test-classes</testOutputDirectory>
    <sourceDirectory>src</sourceDirectory>
    <scriptSourceDirectory>src</scriptSourceDirectory>
    <testSourceDirectory>src</testSourceDirectory>
    <testResources>
        <testResource>
            <directory>test</directory>
        </testResource>
    </testResources>

    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <includes>
                    <include>src</include>
                </includes>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <outputDirectory>lib</outputDirectory>
            </configuration>
        </plugin>

    </plugins>
</build>

推荐答案

我希望你有充分的理由关注标准目录布局,否则考虑重新排列文件夹:它会让你的生活更轻松(如以及您的同事).我的猜测是什么都没有编译.在这种情况下:删除 maven-compiler-plugin 的配置就足够了.

I hope you have good reason not to follow the standard directory layout, otherwise consider to rearrange the folders: it will make your life a lot easier (as well as for your co-workers). My guess is that nothing has been compiled. In that case: removing the configuration of the maven-compiler-plugin should be enough.

这篇关于Maven:JAR 将为空 - 没有内容被标记为包含的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆