Backend Initialization
The ThingsBoard platform is architected with a clear separation between the server-side logic and the client-side interface. The backend, responsible for telemetry processing and device management, is built using Java and Maven.
-
Prerequisites: Verify that JDK (version 11 or newer) and Maven are configured in your system
PATH. -
Build Process: Execute the Maven wrapper to compile the source code and generate the artifact. Skipping tests accelerates the build time.
mvn clean package -DskipTestsThe output artifact (typically a
.jarfile) will be located in theapplication/targetdirectory. -
Database Setup: Before launching, ensure the database schema is initialized. Depending on your OS, execute the corresponding SQL scripts or helper scripts (e.g.,
install_dev_db.batfor Windows or the.shequivalent for Linux) to create tables and insert default configurations. -
Execution: Launch the application using the Java Runtime Environment.
java -jar application/target/thingsboard.jar
Frontend Initialization
The user enterface is developed using the Angular framework. To run it independently from the backend, you must adjust the build configuration.
-
Modify Build Configuration: In the root
pom.xml, comment out or remove the module referencing the UI to prevent Maven from building the frontend alongside the backend. -
Navigate to UI Directory: Change your working directory to the folder containing the frontend code (e.g.,
ui-ngx). -
Dependency Installation: Install the necessary Node.js packages using Yarn or NPM.
yarn install -
Launch Dev Server: Start the local development server. This will serve the application, usually on port 4200, with hot-reload capabilities.
yarn start
Configuration Notes
- CORS Policy: When running the frontend on a different port (e.g.,
4200) and the backend on another (e.g.,8080), ensure the backend Spring Boot configuration allows Cross-Origin Resource Sharing (CORS) from the frontend's origin. - API Endpoint: Verify that the frontend environment configuration (often found in
src/environments/environment.ts) points to the correct backend IP address and port. - Production Deployment: In a production scenario, the Angular application is typicallly compiled into static assets (
ng build) and served via a web server like Nginx, while the backend runs as a system service.