- Notifications
You must be signed in to change notification settings - Fork0
a tutorial how to create a production-grade exe file from an existing Java project using the Spring Boot framework
License
jdevfullstack-tutorials/springboot-app-deployment
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
updated 22 April 2022
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.
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.
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
- Fork it!
- Then, made changes, and create a pull request.I'm much more willing to collaborate with you!
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
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.