When a Maven project generates a jar file, it prompts "no main list attribute", mavenjar
A Maven project is created,mvn compileAndmvn packageGenerate a jar file and then directly gotargetDirectory to executejava -jar xxx.jarWhen running the jar package, the error message "xxx. jar has no main list attribute" is displayed.
Modifypom.xmlFile, add the following configuration items:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>1.2.1</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> <mainClass>com.package.project.App</mainClass> </transformer> </transformers> </configuration> </execution> </executions> </plugin> </plugins></build>
Com. package. project is the package name of the entry class.