Pra*_*dra 3 java launch4j maven-plugin maven spring-boot
我编写了一个插件,在 Launch4J 插件的帮助下为我的项目创建 EXE 和 JAR。但是,在执行 EXE 文件时,我收到错误 -
Error: Could not find or load main class
Run Code Online (Sandbox Code Playgroud)
然而,我通过给运行JAR java -jar app.jar,它运行完美。
这是我的插件部分
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.mycompany.tool.orchestrator.command.CommandHandler</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<version>1.7.16</version>
<executions>
<execution>
<id>l4j-clui</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<headerType>console</headerType>
<outfile>target/apidast.exe</outfile>
<jar>${project.build.directory}/${artifactId}-${version}.jar</jar>
<errTitle>encc</errTitle>
<classPath>
<mainClass>com.mycompany.tool.orchestrator.command.CommandHandler</mainClass>
<!--Not sure what the next 2 lines are for -->
<addDependencies>true</addDependencies>
<preCp>anything</preCp>
</classPath>
<jre>
<minVersion>1.8.0_212</minVersion>
<!--Not sure what these opts are for -->
<opts>
<opt>-Djava.endorsed.dirs=./endorsed</opt>
</opts>
</jre>
<versionInfo>
<fileVersion>0.0.1.0</fileVersion>
<txtFileVersion>0.0.1.0</txtFileVersion>
<fileDescription>${project.name}</fileDescription>
<copyright>My Company.</copyright>
<productVersion>0.0.1.0</productVersion>
<txtProductVersion>${version}</txtProductVersion>
<productName>${project.name}</productName>
<originalFilename>apidast.exe</originalFilename>
<!-- internalName is mandatory -->
<internalName>apidast</internalName>
</versionInfo>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
EXE 存在于我的目标文件夹中。但我无法执行它,因为它说找不到主类(尽管在插件详细信息中添加了它)
尝试对任何 Maven 项目使用以下命令调整 Maven 构建。
mvn clean package 或 mvn clean install
对于Launch4j,您必须运行以下命令。
mvn清理包
有关 Launch4j 的更多详细信息,您可以查看下面的链接。 https://github.com/lukaszlenart/launch4j-maven-plugin/blob/master/src/main/resources/README.adoc
但在这个项目中,我看到你正在使用 spring boot。如果我的理解是正确的,您想在 Spring Boot 之外创建一个 exe 文件。如果是这样的话。
您可以尝试对 launch4j 使用以下更改并检查。
<classPath>
<mainClass>org.springframework.boot.loader.JarLauncher</mainClass>
<addDependencies>true</addDependencies>
<preCp>anything</preCp>
</classPath>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2621 次 |
| 最近记录: |