Compile the class file into a jar package in Java and run the hint without the main manifest property
Maven project Build Jar runtime Prompt "No master manifest attribute"
A new MAVEN project has been created, mvn compile
and a mvn package
jar file has been formed, and then the target
Java -jar xxx.jar
"Xxx.jar no master manifest attribute" error message appears when running the jar package directly to the directory.
According to my experience, there is no way to find the entry class (that is main
, the class where the function is), pom.xml
plus the configuration of the Ingress class in it! For the first time, just use MAVEN to package the jar and record it.
About the executable program (you need to specify a main class) to hit the jar package is not so convenient, we need to consider the following questions:
- The configuration file needs to be hit into the jar package;
- The main entry class needs to be specified;
- The third-party library on which it relies is also required to enter the jar package;
- Only if the above three points are met, we can successfully execute the program directly using the Java-jar Swiftonrsa-1.0.0.jar command.
- 2.1 Configuration file packaging does not require additional attention as long as the configuration files on which your project depends follow the MAVEN specification lil bit location (src/main/resources), the packaged jar package will pack them together:
- But the well-punched jar package does not specify either the main entry class or the dependency package, and we run it:
- Tip "There is no main manifest attribute in Swiftonrsa-1.0.0.jar", we look at the MANIFEST in the Meta-inf directory under the JAR package. MF, the contents are as follows:
manifest-version:1.0
Built-by:defonds
build-jdk:1.7.0_67
Created-by:apache Maven 3.2.3
Archiver-version:plexus archiver
It is true that the main entry class is not indicated.
2.2 Maven-assembly-plugin plug-in so we introduced the Maven-assembly-plugin plug-in, pom.xml add the following code:
- It is true that the main entry class is not indicated.
2.2 Maven-assembly-plugin plug-in so we introduced the Maven-assembly-plugin plug-in, pom.xml add the following code:
[HTML]View PlainCopyprint?
- <build>
- <plugins>
- <plugin>
- <artifactid>maven-assembly-plugin</artifactid>
- <configuration>
- <Appendassemblyid>false</appendassemblyid>
- <descriptorrefs>
- <descriptorref>jar-with-dependencies</descriptorref>
- </descriptorrefs>
- <archive>
Compile the class file into a jar package in Java and run the hint without the main manifest property