The java project is packaged into .exe including third-party dependency packages

The java project is packaged into .exe including third-party dependency packages

If the project that needs to be packaged is useful for other packages, you can add it to the pom.xml file of the maven project

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.4.1</version>
                <configuration>
                    <!-- get all project dependencies -->
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <!-- MainClass in mainfest make a executable jar -->
                    <archive>
                        <manifest>
                            <mainClass>util.Microseer</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <!-- bind to the packaging phase -->
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>

After repackaging, a jar package ending with jar-with-dependencies will be generated. The jar package contains the packages that the project depends on. The .exe file packaged with this jar package will be no problem.

Guess you like

Origin blog.csdn.net/qq_42599616/article/details/105491924