Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

a tutorial how to create a production-grade exe file from an existing Java project using the Spring Boot framework

License

NotificationsYou must be signed in to change notification settings

jdevfullstack-tutorials/springboot-app-deployment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

updated 22 April 2022

Hits

To demonstrate, I'll use my very own project purely written in Java andif you are interested in the project itself, please refer to theoriginal repo of this project.

This repo focuses on how to use the Spring Boot to createa production-grade executable jar file. Spring Boot is concerned with theinfrastructure while you focus on writing your program. Take note, this isnon-web GUI application. It's really that simple to buildand runany of your existing Java program through Spring Boot. IfI have to put web features or to connect to a serverin this project, I can do that easily too in my code and Spring Bootwill take care of the infrastructure.

First, there must be themaven plugin to create the executable jar filein thepom.xml:

<groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId>

Second, you tell Spring Boot the main method of your programbecause it has its own main method.

<configuration><mainClass>xdvrx1ProjectSwing.MainMethod</mainClass></configuration>

And finally, when your program launches GUI, you must setthe headless mode in the SpringMainMethod file to false or else itwill throw aHeadlessException.

SpringApplicationBuilder builder = new SpringApplicationBuilder(SpringMainMethod.class);builder.headless(false);ConfigurableApplicationContext context = builder.run(args);

What others are doing is relying onCommandLineRunner. This is neededwhen you want to trap user inputs on the command line once theSpring Boot is started and before your program runs. In our case here,we don't need that.

Q&A

If you have questions, please utilizetheDiscussions feature of GitHub.

You can also create a pull request or raisean issue to start the discussion or query/ies.

Compile, Build & Run

Before you compile and build, make sure you are at the project directorySpringBootProjectDir of this repo. Take note also, I'm using Maven build tool here.

In Windows,

to package your program as an executable jar file:

mvn clean package

to simply clean and compile:

mvn clean compile

to just clean your project:

mvn clean

to run the program:

mvn spring-boot:run

to build and run the program:

mvn clean install

Contributing

  1. Fork it!
  2. Then, made changes, and create a pull request.I'm much more willing to collaborate with you!

License

MIT - the permissive license

About

a tutorial how to create a production-grade exe file from an existing Java project using the Spring Boot framework

Topics

Resources

License

Stars

Watchers

Forks

Languages


[8]ページ先頭

©2009-2025 Movatter.jp