The vue3+springboot project is packaged as an exe (successful, no native required), the simplest tutorial!

1. Install jdk17

  1. First, our project must be packaged using jdk17 or above.
  2. There is no need to configure environment variables, download the bin style jdk17, and directly enter the bin after decompression.

2. Configure the .net enabling environment

  1. Open "Control Panel": Click the Windows Start menu and select "Control Panel."

  2. Open "Programs" or "Programs and Features": Depending on your version of Windows, select "Programs" or "Programs and Features."

  3. Select "Turn Windows features on or off": In the left panel of the Programs or "Programs and Features" window, you will find the option to "Turn Windows features on or off." click it.Insert image description here

  4. Enable .NET Framework 3.5.1: In the "Windows Features" window, find the checkbox for ".NET Framework 3.5 (includes .NET 2.0 and 3.0)". Select the checkbox and click the "OK" button.Insert image description here

  5. Install .NET Framework 3.5.1: After enabling .NET Framework 3.5.1, the system will automatically download and install the required files. This may take some time, so please be patient.

  6. Complete installation: Once the installation is complete, you will receive a success message.

3. Install wix 3

  1. Then download the wix version 3 or above address Release WiX Toolset v3.11.2 · wixtoolset/wix3 (github.com)

  2. Configure path: If there is no choice during installation, generally configure this path into the environment variable path here.Insert image description here

  3. Use the command to test whether the installation is successful

    candle.exe
    light.exe
    
  4. Execute compilation (if you execute this command without configuring environment variables for jdk17 or above, you need to enter the bin of jdk17 and open the cmd command line window to execute):

    jpackage --type exe --input <path_to_jar> --main-jar <jar_file> --name <output_name> --win-dir-chooser --icon <icon_file_path>
    

    Insert image description here

    Enter cmd in the address bar to open the command line window and execute the command

    • <path_to_jar>:Specify the JAR file path of your Spring Boot application.
      • <jar_file>:Specify the main JAR file name of your Spring Boot application.
      • <output_name>: Specify the name of the output EXE file.
      • --icon <icon_file_path>Set icon path

    --win-dir-chooserOptions allow the user to select the installation directory.

    You can add other options as needed, such as specifying the output directory, setting an icon, adding an application description, etc.

  5. Execute jpackagethe command: Run the above jpackagecommand, which will use jpackagetools to package your Spring Boot application into an executable EXE file.

Please note that jpackagethe specific parameters and options of the command may vary depending on the Java version used. You can use jpackage --helpthe command to see the available options and syntax.

The following is an example command

eg:

jpackage --type exe --input D:\project\My\docker\middlewareDeploy\target --main-jar middlewareDeploy-0.0.1-SNAPSHOT.jar --name MiddlewareDeploy --win-dir-chooser

4. The front-end vue3 and the back-end springboot3 are packaged as exe

This is a demonstration example. After the user completes a project in which the front and back ends are separated, the front end and back end can be directly packaged into an exe. In this way, you can send this exe directly to other people's computers and use it directly.

1. Package the front-end project vue3:

  1. Excuting an order

     pnpm run build
    
  2. Then you will see the dist folder in the vue3 projectInsert image description here

  3. Then place the files in the dist folder in the corresponding locations in the springboot project.Insert image description here

  4. Start the project to see if it runs successfully. Of course, the template engine is used to open the vue3 page.Insert image description here

2. Package springboot project

  1. Confirm that the environment in the first three steps of the environment has been installed. Execute command to view

    candle.exe
    light.exe
    
  2. Then go to the bin directory of jdk17 and open the command line window to execute the command.

    jpackage --type exe --input <path_to_jar> --main-jar <jar_file> --name <output_name> --win-dir-chooser --icon <icon_file_path>
    
  3. Wait two minutes after executing the command. After the packaging is completed, an exe starting with the name in the command will appear in the bin directory. This is how the project is packaged as an exe. Then install and start.

Guess you like

Origin blog.csdn.net/qq_63946922/article/details/132721173