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:
Enable the automatic import of dependencies in the IDE, or run the
mvn clean installcommand in the project root directory to download the dependencies.Run the
mainfunction under thewebmodule to start the SOFABoot web project.
Running via mvn spring-boot:run
The main steps are as follows:
Execute the cd command to go to the project root directory. Example:
C:\Users\user_Name\SOFABootWebProjectExecute the
mvn clean installcommand to download the dependencies.Execute the cd command to go to the root directory where the
webmodule is located. Example:C:\Users\user_Name\SOFABootWebProject\app\webExecute
mvn spring-boot:runcommand.
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:
Execute the cd command to go to the project root directory. Example:
C:\Users\user_Name\SOFABootWebProjectExecute the
mvn packageormvn clean installcommand, the SOFABoot project will be packaged as a{XXX}-executable.jarfile and stored in thetargetdirectory of the project root directory.Execute the cd command to go to the
targetdirectory of the project.Execute the
java -jar XXX-executable.jarcommand 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:8080

http://localhost:8341/webapi/users/aliBaby
NoteYou 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:
Execute the
mvn clean installcommand in the project root directory to download the dependencies.Run the
mainfunction in theservicemodule to start the SOFABoot Core project.
Running via mvn spring-boot:run
The main steps are as follows:
Run the cd command to go to the project root directory. Example:
C:\Users\user_Name\SOFABootCoreProjectRun the
mvn clean installcommand to download the dependencies.Run the cd command to go to the root directory where the
servicemodule is located. Example:C:\Users\user_Name\SOFABootWebProject\SOFABootWebProject-serviceExecute
mvn spring-boot:runcommand.
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:
Run the cd command to go to the project root directory. Example:
C:\Users\user_Name\SOFABootCoreProjectExecute the
mvn packageormvn clean installcommand, the SOFABoot project will be packaged as a{XXX}-executable.jarfile and stored in thetargetdirectory of the project root directory.Run the cd command to go to the
targetdirectory of the project.Run the command
java -jar XXX-executable.jarto 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.