The Springboot jar package is registered as an executable exe service

The Springboot jar package is registered as an executable exe service, and the self-guided jre operating environment is installed and deployed with one click.

Specifically divided into the following three steps.

  1. Package the springboot project into an executable jar file
  2. Use exe4j to package the jar package into an executable exe file
  3. Use innosetup to compile exe into a service (this step can be ignored if you deploy it according to your own wishes)

1. Package the springboot project into an executable jar file

There is no tutorial for this, just use mvn package to package it into a jar file.

Packaged into a jar file

2. Use exe4j to package the jar package into an executable exe file

  1. Download and install exe4j
    link: https://pan.baidu.com/s/1LLU5-57mCUOni8BqbT9yZQ
    Extraction code: r5og

  2. Open exe4j, configure the license, you can find one on the Internet, the following is the license I am looking for: "L-g782dn2d-1f1yqxx1rv1sqd"insert image description here

  3. Click open to select the configuration, because I have already created it, so I will not create it.insert image description here

  4. Select "JAR in EXE" modeinsert image description here

  5. Configuration file name and file directory address, this should be remembered.insert image description here

  6. Now computers are generally 64-bit, choose 64-bit for compilation.insert image description here

  7. Add the jar package and specify the main method entry. You can also configure some vm parameters. Since I am using an external configuration file. So I configured some VM parameters. insert image description here
    insert image description here
    This is my vm parameter configuration. If you don’t need it, you can fill it in according to your own needs or leave it blank.
    -Xverify:none -Dfile.encoding=utf-8 -XX:TieredStopAtLevel=1 -Dspring.profiles.active=dll
    insert image description here

  8. Specify the jre version and directory, and it is best to use a relative path for the directory.
    insert image description here
    insert image description here
    insert image description here

insert image description here
9. After the configuration is complete, you can continue to compile until the end.
insert image description here
10. We go to the directory configured in the fifth step at the beginning, and we can see an exe file. insert image description here
11. Since our eighth step is to use the relative path configuration of jre, we prevent the jre directory from being under the relative path of the exe file. ( You can choose not to configure : since I need to specify the external configuration yml file, I added the config file directory to the relative path of the exe, which is my configuration file)insert image description here

insert image description here
At this point, we should be able to run the package by double-clicking the exe. Below is my splash screen.
insert image description here

At this point, the exe compilation can basically be realized. According to the actual situation, you can see if you need to register the exe as a service in the next step.

3. Use inno setup to compile exe and register it as a service.

  1. Download and install the Inno Setup compiler
    Baidu network disk address download address
    Extraction code: bebo
    follow-up is normal installation. I won't explain too much
  2. Click file in the upper left corner to create a new scriptinsert image description here
  3. Set the application name and other information
    insert image description here
    insert image description here
    Of course, you can also customize the installation directory. It's up to you to chooseinsert image description here
  4. Select the exe file generated by exe4j above. And select the jre and config directoriesinsert image description here
  5. Keep going to the next step until you need to configure the output directory and installation package name later.
    insert image description here
    6. Click Next to generate the script, do not run it at this time, modify it first.
    insert image description here
  6. Click Run to compileinsert image description here
  7. After the compilation is completed, there will be an exe package in the output directory configured in the fifth step. We see that this package is still quite large, because it contains our jre and external configuration files. Of course, you can find a way to simplify jre, and there will be no teaching here.
    insert image description here
  8. Double-click the exe file to install and then register as a service.
    insert image description here
    9. After the installation is complete, our directory will look like this. Double-click the exe to run it, and of course the start menu will also have services.
    insert image description here
    insert image description here
    The whole process is roughly like this. I hope everyone can go through it step by step. After all, there are too few tutorials on the Internet, and I stepped on a lot of pitfalls. But in the end it was successful, and I was very pleased.

Guess you like

Origin blog.csdn.net/qq_42900469/article/details/130585781