简体   繁体   中英

How to generate jar file from spring boot application using gradle?

I am creating a spring boot application using gradle. I need to create a jar which include all needed libraries for deploying on (aws) ec2 instance.


I am trying to create a jar by...

1)click on project structure

2)then click on Artifact

3)click on + -> jar -> from modules with dependencies -> select project -> select main class

4)click on ok with default settings

5)click on build tab

6)I got a jar file but it doesn't contain classes.

Use Terminal/Command Prompt to generate jar using Gradle

To generate jar without running test cases

./gradlew build -x test

If you want to run the test cases before creating jar, then

./gradlew build

First make sure you have downloaded gradle and set up in your system variable. to check this simply run gradle -v in your cmd.

Under System Variables select Path, then click Edit. Add an entry for C:\Gradle\gradle-6.5.1\bin. Click OK to save.

Now you simply goes to project directory and run

./gradlew build -x test

Now you get your executable jar file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM