Skip to content

Local Run and Deployment ​

​

1. Local Environment Preparation ​

Java Environment ​

Make sure a suitable version of the Java Development Kit (JDK) is installed locally; JDK 17 or above is recommended. You can check the installation and version information by running the java -version command on the command line. If it is not installed, go to Oracle's official website (for Oracle JDK) or another reliable open-source JDK provider (such as the OpenJDK website) to download the corresponding version and complete the installation following the installation wizard.

Database Environment ​

The database type used by the project is MySQL. Install the corresponding database management system and configure it correctly.

Maven ​

​ The project is built with Maven, so you need to install Maven and configure the local repository path and mirror source (in China, you can configure a mirror such as the Alibaba Cloud mirror to speed up dependency downloads). You can verify the installation by running mvn -v on the command line.

Frontend Environment Installation: ​

  • Node.js: the version must be greater than 18.18.0. Go to the official Node.js website (https://nodejs.org/) to download and install the Long-Term Support (LTS) version of Node.js. After installation, run node -v and npm -v on the command line to check whether Node.js and its package manager npm are installed successfully and meet the project requirements.

  • Frontend build tool Vite: if you have not installed pnpm yet, run the following command to install it (mac users who encounter installation errors should prefix the command with sudo)

    ruby
    npm install -g pnpm
  • Frontend dependency installation: run the following command in the frontend project root directory. This installs all frontend dependency packages according to the project's package.json file. The installation may take some time, depending on network conditions and the number of dependencies.

    bash
    pnpm install

2. Running in IDEA ​

Adding VM Run Parameters ​

Some permissions need to be enabled in the virtual machine runtime environment, so the following run parameters need to be added:

json
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
Add VM run parameters page screenshot

Database File ​

Execute the database file. Currently only MySQL is supported; the SQL file must be requested from customer service.

Packaging the Frontend and Integrating It into the Backend for Deployment ​

Method 1: run the following command in the frontend to package it, then copy the packaged files to the backend fbmq-application/src/main/resources/static

Method 2: run the backend packaging command maven package directly; after it completes, the frontend is automatically packaged into the backend fbmq-application/src/main/resources/static

Running the Spring Boot Startup Class ​

Click the Spring Boot startup class. When the following success banner appears, the startup is successful.

tex
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *      
 *           _⚲_⚲_            ______        _     ____                   *       
 *     |   /       \   |     |  ____|      | |   |  _ \                  *     
 *     |  |  | ● |  |  |     | |__ __ _ ___| |_  | |_) | ___  ___        *       
 *     |   \       /   |     |  __/ _` / __| __| |  _ < / _ \/ _ \       *    
 *           \   /           | | | (_| \__ \ |_  | |_) |  __/  __/       *    
 *             V             |_|  \__,_|___/\__| |____/ \___|\___|       *   
 *                                                                       *       
 * * * * * * * * * * * * FastBee物联网平台[✔启动成功] * * * * * * * * * * * *

3. Deployment ​

Database Configuration ​

Import the database SQL file; the SQL file must be obtained from customer service. Configure the imported database. Currently only MySQL is supported.

sql
fastbee:
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/fmq?useSSL=false
    username: root
    password: fastbee

Cluster Configuration ​

Local run IP configuration, as follows:

yml
fastbee:
  cluster: # cluster configuration
    localAddress: 127.0.0.1
    addresses: [ "127.0.0.1" ] # internal network address
    node-id: fastbee # node id

Cluster configuration: use internal network IPs for the IP addresses.

yml
  fastbee:
  cluster: # cluster configuration
    localAddress: 10.0.xx.xx
    addresses: ["10.0.xx.xx","10.0.xx.xx"] # internal network address
    node-id: fastbee1 # node id

Packaging ​

First run maven clean to clear the cache, then run maven package to package and get the jar package.

Deployment Files ​

Copy the deployment files to the server (contact customer service to obtain them).

Execute the .sh file to register the service with the system systemctl. The sh file is as follows:

sh
#!/bin/bash
set -e

# Application name, can be passed as a command-line argument; the default value is used if not passed
APP_NAME="${1:-fbmq-application.jar}"
# Application directory, determined by the directory of the current script
APP_DIR=$(pwd)
# Assume the JRE directory is jre, in the same directory as the project; can be passed as a command-line argument; the default value is used if not passed
JRE_DIR="${3:-$APP_DIR/vjre}"

# Log file path, can be passed as a command-line argument
LOG_FILE="${2:-$APP_DIR/app.log}"

service_name="fbmq"

service_description="fbmq"
....

Starting the Service ​

Run systemctl start fbmq to start the service.

sh
systemctl start fbmq   // start
systemctl status fbmq  // check status
systemctl stop fbmq    // stop

Run systemctl status fbmq to check whether it started successfully. Startup completion banner:

tex
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *      
 *           _⚲_⚲_            ______        _     ____                   *       
 *     |   /       \   |     |  ____|      | |   |  _ \                  *     
 *     |  |  | ● |  |  |     | |__ __ _ ___| |_  | |_) | ___  ___        *       
 *     |   \       /   |     |  __/ _` / __| __| |  _ < / _ \/ _ \       *    
 *           \   /           | | | (_| \__ \ |_  | |_) |  __/  __/       *    
 *             V             |_|  \__,_|___/\__| |____/ \___|\___|       *   
 *                                                                       *       
 * * * * * * * * * * * * FastBee物联网平台[✔启动成功] * * * * * * * * * * * *

​

​

FastBee | fastbee.cn