我有一个jar文件,它与UI捆绑在一起,现在我想制作一个独立的窗口可执行文件。在jar文件中,我有PostgreSQL数据库tomcat服务器的代码我的项目pom文件,如
我只想要一个直接在双击上运行的exe
<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">
<parent>
<groupId>dev.marco</groupId>
<artifactId>java-angular-example</artifactId>
<version>0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.outputEncoding>UTF-8</project.build.outputEncoding>
</properties>
<artifactId>backend</artifactId>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>frontend</artifactId>
<version>${project.version}</version>
<type>jar</type>
</dependency>
....
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<mainClass>dev.marco.ShlowinApplication</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
</project>
我能想到的最接近的是launch4j,为您的应用程序添加一个exe启动器。这将添加exe,但不会神奇地使其成为桌面应用程序,为此您可能需要调整代码。
pom.xml中的配置看起来类似于以下内容:
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>l4j-gui</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>gui</headerType>
<outfile>target/${project.artifactId}.exe</outfile>
<jar>target/${project.artifactId}.jar</jar>
<dontWrapJar>false</dontWrapJar>
<addDependencies>true</addDependencies>
<errTitle>Error in launch4j plugin</errTitle>
<classPath>
<mainClass>${mainClass}</mainClass>
</classPath>
<icon>src/main/resources/Images/logo.ico</icon>
<jre>
<path>./java</path>
</jre>
<versionInfo>
<fileVersion>${project.version}.0</fileVersion>
<txtFileVersion>${project.version}.0</txtFileVersion>
<fileDescription>${description}</fileDescription>
<copyright>Copyright(c) ${distributor}</copyright>
<companyName>${distributor}</companyName>
<productVersion>${project.version}.0</productVersion>
<txtProductVersion>${project.version}.0</txtProductVersion>
<productName>${project.artifactId}</productName>
<internalName>${project.artifactId}</internalName>
<originalFilename>${project.artifactId}.exe</originalFilename>
<language>ENGLISH_UK</language>
</versionInfo>
</configuration>
</execution>
</executions>
</plugin>