Skip to content

Installation Guide

Doc Version: 1.0.2
Last Updated: 2026-05-21
Git Commit: 61384b4a
Author: Lincoln

This guide provides a detailed introduction to installing and building JAiRouter in different environments.

Environment Requirements

System Requirements

ComponentMinimum VersionRecommended VersionDescription
JDK1721+Supports OpenJDK and Oracle JDK
Maven3.6.03.9+Optional, the project includes the Maven Wrapper
Docker20.1024+Used for containerized deployment
Memory512MB1GB+Runtime memory requirements
Disk Space1GB2GB+Includes space for dependencies and logs

Supported Operating Systems

  • Windows: Windows 10/11, Windows Server 2019+
  • Linux: Ubuntu 18.04+, CentOS 7+, RHEL 7+, Debian 10+
  • macOS: macOS 10.15+

Choosing an Installation Method

JAiRouter offers multiple installation methods. Choose according to your needs:

Installation MethodSuitable ScenariosAdvantagesDisadvantages
Docker DeploymentProduction environments, quick experienceEnvironment isolation, easy deploymentRequires a Docker environment
Traditional DeploymentDevelopment environments, system integrationRuns directly, easy to debugRequires configuring the Java environment
Source Code BuildDevelopment contributions, customizationFull control, customizableRequires a development environment

Docker installation is the simplest and fastest method and is suitable for most users.

1. Install Docker

If you do not have Docker installed yet, refer to the Docker official installation guide.

2. Pull the Image

# Pull the latest version
docker pull sodlinken/jairouter:latest

# Or pull a specific version
docker pull sodlinken/jairouter:v0.3.1

3. Run the Container

# Basic run
docker run -d \
  --name jairouter \
  -p 8080:8080 \
  sodlinken/jairouter:latest

# Run with a configuration file
docker run -d \
  --name jairouter \
  -p 8080:8080 \
  -v $(pwd)/config:/app/config:ro \
  -v $(pwd)/logs:/app/logs \
  sodlinken/jairouter:latest

4. Verify the Installation

# Check the container status
docker ps --filter "name=jairouter"

# View the logs
docker logs jairouter

# Test the API
curl http://localhost:8080/actuator/health

Traditional Installation

The traditional installation method runs the JAR file directly on the system and is suitable for development and debugging.

1. Install Java

Make sure JDK 17 or higher is installed on your system:

# Check the Java version
java -version

# Should show output similar to:
# openjdk version "17.0.2" 2022-01-18

If Java is not installed, download it from one of the following channels: - OpenJDK - Oracle JDK - Amazon Corretto

2. Download the JAR File

Download the latest JAR file from GitHub Releases:

# Visit the Releases page to download
# https://github.com/Lincoln-cn/JAiRouter/releases

# Or use the command line (replace VERSION with the actual version number)
wget https://github.com/Lincoln-cn/JAiRouter/releases/download/vVERSION/model-router-VERSION.jar

3. Run the Application

# Basic run
java -jar model-router.jar

# Specify a configuration file
java -jar model-router.jar --spring.config.location=classpath:/application.yml

# Specify JVM parameters
java -Xmx1g -Xms512m -jar model-router.jar

# Run in the background
nohup java -jar model-router.jar > jairouter.log 2>&1 &

4. Verify the Installation

# Check the process
ps aux | grep model-router

# Test the API
curl http://localhost:8080/actuator/health

Building from Source

Building from source is suitable for developers and users who need customization.

1. Clone the Code

git clone https://github.com/Lincoln-cn/JAiRouter.git
cd jairouter

2. Choosing a Build Method

JAiRouter offers multiple build methods, optimized for different user groups and network environments:

Build MethodTarget UsersMaven RepositoryBuild SpeedRecommendation
China AcceleratedChinese usersAlibaba Cloud mirrorFast⭐⭐⭐⭐⭐
Standard BuildInternational usersMaven CentralNormal⭐⭐⭐
Fast BuildDevelopment and debuggingSkips testsFastest⭐⭐⭐⭐

Optimized Features

  • Alibaba Cloud Maven Mirror: uses https://maven.aliyun.com/repository/public
  • Full Repository Support: mirrored repositories for Central, Spring, Plugin, etc.
  • Automatic Configuration: built-in settings.xml, no manual configuration required
  • Significant Speedup: dependency download speed improved 5-10x

Build Commands

# Use the Maven Wrapper (recommended)
./mvnw clean package -Pchina

# Or use the system Maven
mvn clean package -Pchina

# Use the dedicated configuration file
mvn clean package -s settings-china.xml
├── Dockerfile.china              # China-optimized Docker build file
├── settings-china.xml            # Alibaba Cloud Maven mirror configuration
├── scripts/docker-build-china.sh # China-optimized build script
└── pom.xml (china profile)       # Maven China acceleration configuration

4. Standard Build for International Users

Use the standard Maven Central repository:

# Use the Maven Wrapper (recommended)
./mvnw clean package

# Or use the system Maven
mvn clean package

5. Fast Build (Development and Debugging)

Suitable for development environments and quick testing:

# Skip all checks and tests
./mvnw clean package -Pfast

# Skip tests only
./mvnw clean package -DskipTests

# Skip code quality checks
./mvnw compiler:compile compiler:testCompile surefire:test

6. Build Performance Comparison

Build MethodFirst Build TimeIncremental Build TimeNetwork RequirementsSuitable Scenarios
China Accelerated1-2 minutes30-60 secondsChina networkDaily development for Chinese users
Standard Build5-10 minutes2-3 minutesInternational networkDevelopment for international users
Fast Build30-60 seconds10-20 secondsAnyDevelopment and debugging

7. Run the Build Result

# Run the built JAR file
java -jar target/model-router-*.jar

# Run with a specified configuration file
java -jar target/model-router-*.jar --spring.config.location=classpath:/application.yml

# Specify JVM parameters
java -Xmx1g -Xms512m -jar target/model-router-*.jar

Building Docker Images

If you need to build a custom Docker image:

JAiRouter provides build scripts optimized for different user groups:

# Chinese users (use the Alibaba Cloud mirror, fast build)
./scripts/docker-build-china.sh

# International users (use the standard image)
./scripts/docker-build.sh

# Windows users
.\scripts\docker-build.ps1

2. Manual Build

China-Optimized Build for Chinese Users

# Use the China-optimized Dockerfile
docker build -f Dockerfile.china -t sodlinken/jairouter:latest .

Dockerfile.china features: - Automatically configures the Alibaba Cloud Maven mirror during the build stage - Builds using the china profile - Optimized multi-stage build process

Standard Build for International Users

# Use the standard Dockerfile
docker build -t sodlinken/jairouter:latest .

3. Use Maven Plugins

# Use the Dockerfile plugin
mvn clean package dockerfile:build -Pdocker

# Use the Jib plugin (no Docker required)
mvn clean package jib:dockerBuild -Pjib

# Chinese users use the Jib plugin
mvn clean package jib:dockerBuild -Pjib,china

4. Detailed Build Process

The Docker build includes the following stages:

  1. Preparation stage: Copy the source code and configuration files
  2. Dependency download: Download dependencies from the configured Maven repository
  3. Compile and build: Compile the Java code and package it
  4. Image packaging: Create the final runtime image

5. Build Optimization Suggestions

For Chinese Users

  • Prefer using ./scripts/docker-build-china.sh
  • Configure the local Docker to use a domestic mirror for acceleration
  • Use multi-stage builds to reduce image size

For International Users

  • Use the standard build script
  • Configure a Docker proxy (if needed)
  • Leverage Docker layer caching to improve build speed

Development Environment Installation

The development environment requires additional tools and configuration.

1. IDE Configuration

The following IDEs are recommended: - IntelliJ IDEA: Recommended, built-in Spring Boot support - Eclipse: Requires installing Spring Tools Suite - VS Code: Requires installing the Java and Spring Boot extensions

2. Development Tools

# Install Maven (if not using the Wrapper)
# Ubuntu/Debian
sudo apt install maven

# CentOS/RHEL
sudo yum install maven

# macOS
brew install maven

# Windows
# Download and configure the environment variables

3. Code Quality Tools

The project integrates multiple code quality tools:

# Run code checks
./mvnw checkstyle:check

# Run static analysis
./mvnw spotbugs:check

# Generate a coverage report
./mvnw jacoco:report

4. Run in Development Mode

# Use the Spring Boot Maven plugin
./mvnw spring-boot:run

# Enable debug mode
./mvnw spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"

# Use the development profile
./mvnw spring-boot:run -Dspring-boot.run.profiles=dev

Troubleshooting

Common Issues

1. Incompatible Java Version

# Error message: UnsupportedClassVersionError
# Solution: upgrade to JDK 17+

# Check the Java version
java -version
javac -version

# Set JAVA_HOME
export JAVA_HOME=/path/to/jdk17

2. Port Already in Use

# Error message: Port 8080 was already in use
# Solution: change the port or stop the process occupying it

# Find the process occupying the port
netstat -tulpn | grep 8080
lsof -i :8080

# Change the port
java -jar model-router.jar --server.port=8081

3. Insufficient Memory

# Error message: OutOfMemoryError
# Solution: increase JVM memory

# Set memory parameters
java -Xmx2g -Xms1g -jar model-router.jar

4. Dependency Download Failure

# Chinese users use the Alibaba Cloud mirror
./mvnw clean package -Pchina

# Or configure a proxy
./mvnw clean package -Dhttp.proxyHost=proxy.example.com -Dhttp.proxyPort=8080

5. Docker Build Failure

# Check the Docker version
docker --version

# Clean the Docker cache
docker system prune -a

# Rebuild
docker build --no-cache -t sodlinken/jairouter:latest .

Getting Help

If you encounter other problems, please:

  1. Check the Troubleshooting documentation
  2. Search GitHub Issues
  3. Submit a new Issue

Troubleshooting

Common Issues

1. Port Already in Use

Problem: Port 8080 was already in use

Solution:

# Find the process occupying the port
netstat -tulpn | grep 8080
lsof -i :8080

# Change the port
java -jar model-router.jar --server.port=8081

2. Incompatible Java Version

Problem: Unsupported class file major version

Solution:

# Check the Java version
java -version

# Install JDK 17+
# Ubuntu/Debian
apt-get install openjdk-17-jdk

# CentOS/RHEL
yum install java-17-openjdk

3. Insufficient Memory

Problem: OutOfMemoryError

Solution:

# Increase JVM memory
java -Xmx2g -Xms1g -jar model-router.jar

4. Dependency Download Failure

Problem: Maven dependency download times out or fails

Solution:

# Chinese users use the Alibaba Cloud mirror
./mvnw clean package -Pchina

# Or configure a proxy
./mvnw clean package -Dhttp.proxyHost=proxy.example.com -Dhttp.proxyPort=8080

5. Docker Build Failure

Problem: Docker image build fails

Solution:

# Check the Docker version
docker --version

# Clean the Docker cache
docker system prune -a

# Rebuild
docker build --no-cache -t sodlinken/jairouter:latest .

Next Steps

After installation, you can:

  1. Quick Start - Experience JAiRouter in 5 minutes
  2. First Steps - Configure your first AI service
  3. Configuration Guide - Detailed configuration instructions