Maven:JAR将为空 - 没有内容标记为包含 [英] Maven: JAR will be empty - no content was marked for inclusion
问题描述
我对maven有一个小问题。当我运行命令mvn包时,我收到以下警告:
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屋!