Local execution

更新时间:
复制 MD 格式

You can execute the project locally using an IDE, Maven, or Java command-line tools. This article describes how to build and run SOFABoot Web projects and Core projects locally.

Building and Running the Web Project

Download the demo

Click to download the sample project:websofademo.7z.

Running Locally in an IDE

The main steps are as follows:

  1. Enable the automatic import of dependencies in the IDE, or run the mvn clean install command in the project root directory to download the dependencies.

  2. Run the main function under the web module to start the SOFABoot web project.

Running via mvn spring-boot:run

The main steps are as follows:

  1. Execute the cd command to go to the project root directory. Example:

    C:\Users\user_Name\SOFABootWebProject

  2. Execute the mvn clean install command to download the dependencies.

  3. Execute the cd command to go to the root directory where the web module is located. Example:

    C:\Users\user_Name\SOFABootWebProject\app\web

  4. Execute mvn spring-boot:run command.

In SOFABoot Web projects, the main function resides in the web module by default. Since the Spring Boot Maven plugin is pre-configured in this module, you must navigate to the web module's directory to execute Command 4 (referenced above) for building and running the project.

During command execution, the default spring-boot-maven-plugin automatically configures the project archetype. No modifications are required unless specific customizations are needed.

Running via java -jar

The main steps are as follows:

  1. Execute the cd command to go to the project root directory. Example:

    C:\Users\user_Name\SOFABootWebProject

  2. Execute the mvn package or mvn clean install command, the SOFABoot project will be packaged as a {XXX}-executable.jar file and stored in the target directory of the project root directory.

  3. Execute the cd command to go to the target directory of the project.

  4. Execute the java -jar XXX-executable.jar command to compile and run the project.

If you want to test on a private server (with the corresponding version of JDK installed), copy the {XXX}-executable.jar file generated in step 2 above to the server, and then use the java -jar XXX-executable.jar command line to execute the file.

Build result verification

After you run the project by using one of the preceding methods, you can use a browser to access one of the following URLs to run the project and verify the result.

  • http://localhost:80808080页面反馈

  • http://localhost:8341/webapi/users/aliBaby

    8341返回页面

    Note

    You can customize the aliBaby part in the URL.

Building and Running the Core project

Download the demo

Click to download the sample project: coresofademo.zip.

Running Locally in an IDE

The main steps are as follows:

  1. Execute the mvn clean install command in the project root directory to download the dependencies.

  2. Run the main function in the service module to start the SOFABoot Core project.

Running via mvn spring-boot:run

The main steps are as follows:

  1. Run the cd command to go to the project root directory. Example:

    C:\Users\user_Name\SOFABootCoreProject

  2. Run the mvn clean install command to download the dependencies.

  3. Run the cd command to go to the root directory where the service module is located. Example: C:\Users\user_Name\SOFABootWebProject\SOFABootWebProject-service

  4. Execute mvn spring-boot:run command.

By default, the main functions of the SOFABoot web project are in the service module, and the Maven plug-in of Spring Boot is configured in the service module. Therefore, you need to switch to the directory where the service module is located and run the above command 4 to compile and run the project.

During the preceding command execution, the default spring-boot-maven-plugin plug-in automatically configures the project prototype. If you have no special requirements, you do not need to modify it. For more information, see the spring-boot-maven-plugin instructions.

Running via java -jar

The main steps are as follows:

  1. Run the cd command to go to the project root directory. Example:

    C:\Users\user_Name\SOFABootCoreProject

  2. Execute the mvn package or mvn clean install command, the SOFABoot project will be packaged as a {XXX}-executable.jar file and stored in the target directory of the project root directory.

  3. Run the cd command to go to the target directory of the project.

  4. Run the command java -jar XXX-executable.jar to compile and run the project.

If you want to test on a private server (with the corresponding version of JDK installed), copy the {XXX}-executable.jar file generated in step 2 above to the server, and then use the java -jar XXX-executable.jar command line to execute the file.

Build result verification

The SOFABoot Core project is a project without pages, so the effect preview cannot be performed locally. However, it can be health check by accessing the http://localhost:8080/actuator/readiness address. If the status is UP, the creation is successful.

More reference

After the test is complete, you can deploy the project to SOFAStack to provide application services for more users. For more information, see SOFABoot in the cloud.