无法从Spring Boot,Gradle和IntelliJ-Idea生成可执行的jar文件 [英] Can't produce an executable jar from Spring Boot, Gradle, and IntelliJ-Idea

查看:499
本文介绍了无法从Spring Boot,Gradle和IntelliJ-Idea生成可执行的jar文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个使用IntelliJ-Idea和Gradle作为构建引擎的Spring Boot Microservice。我没有改变最初的Spring Boot配置。我也没有对提供的 build.gradle 文件进行修改。我使用 starter.spring.io 通过IntelliJ-Idea构建了应用程序,并具有以下依赖项:

 编译('org.springframework.boot:spring-boot-starter-data-jpa')
编译('org.springframework.boot:spring-boot-devtools')
compile('org。 springframework.boot:spring-boot-starter-web')
runtime('org.postgresql:postgresql')
testCompile('org.springframework.boot:spring-boot-starter-test')

该应用程序目前包含12个类和2个接口,并且是Web服务提供者。它在我的系统上运行良好,但是当我使用Gradle构建时,Manifest.MF不包含 Main-Class 条目。

我创建了一个非常简单的Hello World应用程序,并尝试了IDE和构建工具(Gradle和Maven)
的几种组合,并得到以下结果:






有趣的是,我能够在Eclipse中生成可执行的JAR文件,该JAR文件具有独立的Runnable JAR导出过程。



我对IntelliJ和Gradle相当陌生。有没有人看到过这种行为?任何想法,我可能在IntelliJ中做错了?我有我的Hello World项目,如果有人需要的话,我会将其压缩。

我接受了 M的建议。 Denium ,我从命令行完成了Gradle构建。创建的jar被正确格式化为可执行文件。一切都像魅力一样工作。实际上,Main-Class是一个名为 org.springframework.boot.loader.JarLauncher 的Spring Boot类,我的应用程序的主类位于名为 Start-Class 的属性中。 。 IDE完全错过了这一点。

I have created a Spring Boot Microservice using IntelliJ-Idea and Gradle as the build engine. I have made no changes to the initial Spring Boot configuration. I also have made no modifications to the build.gradle file provided. I built the application using starter.spring.io through IntelliJ-Idea and have the following dependencies:

compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-devtools')
compile('org.springframework.boot:spring-boot-starter-web')
runtime('org.postgresql:postgresql')
testCompile('org.springframework.boot:spring-boot-starter-test')

The application currently contains 12 classes and 2 interfaces and is a Web Service provider. It runs fine on my system but when I build with Gradle, the Manifest.MF contains no Main-Class entry.

I created a very simple Hello World app and tried several combinations of IDE’s and build tools(Gradle and Maven) and got the following results:  

 

Interestingly, I was able to produce executable jars in Eclipse which has a separate Runnable JAR Export process.

I'm fairly new to IntelliJ and Gradle. Has anyone see this behavior before? Any ideas what I might be doing wrong in IntelliJ? I have my Hello World project zipped up if anyone needs it.

解决方案

I took the advise of M. Denium and I did the Gradle build from the Command Line. The jars created were formatted correctly to be executable. Everything worked like a charm. In fact the Main-Class is a Spring Boot class called org.springframework.boot.loader.JarLauncher and the main class for my app was in a property called Start-Class. The IDE totally misses this.

这篇关于无法从Spring Boot,Gradle和IntelliJ-Idea生成可执行的jar文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆