The solution to running the jar package to report no main manifest attribute, in XXXX

Solution to package and run report no main manifest attribute, in XXXX

This problem is mainly because the Main-Class main class is not specified in the MANIFEST.MF file

Three ways:

1. Specify the startup Main-Class main class in the content of the MANIFEST.MF file

2. Add the following code to the pom file and repackage

<build>
     <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                            <goal>build-info</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

3. In general, when java is packaged into a jar package, you need to specify the Main-Class item in MANIFEST.MF, so that you can find the corresponding main class when running java -jar xxx.jar. Because -jar means that the following jar package has a main class that can run independently, so you need to specify this class when packaging it into a jar package; otherwise, you need to specify it manually during execution.
Solution:
Use -cp / --classpath to manually specify when running the jar package.
java -cp xxx.jar com.juanxinc.xxx.class name

eg: java -cp uninstaller.jar uninstall
 

can

Guess you like

Origin blog.csdn.net/qq_32824605/article/details/129244386