Java – Maven: the jar will be empty – nothing is marked as contained
•
Java
I have a little problem with Maven When I run the command MVN package, I get the following warning:
[warning] jar will be empty – nothing is marked as contained!
The build was successful, but the generated jar file was empty because the warning said
Why? What did I do wrong?
This 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>
Solution
I hope you have a good reason not to follow the standard directory layout, or consider rescheduling your folders: this will make your life easier (and colleagues) My guess is that it has not been edited In this case, it should be sufficient to delete the configuration of Maven compiler plugin
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码