This guide uses DeployHQ to automate deployments of your Java Spring project.

> **New in 2026 — Managed VPS hosting**: DeployHQ now offers [Managed VPS Hosting](https://www.deployhq.com/hosting/managed-vps) — fully-managed Linux servers with built-in CI/CD. Spring Boot JARs run cleanly on Managed VPS under systemd. The walkthrough below covers Tomcat-based BYO deployment, which remains fully supported.

**Prerequisites:**

-   A hosted server with Java and Maven installed.

### Setting Up DeployHQ

1.  **Create a DeployHQ project:** Sign up and navigate to **Projects** > **New Project**. Follow the wizard to connect your project repository.
2.  **Create a DeployHQ user:** Enhance security by creating a dedicated user for deployments:

```
sudo adduser deployhq
sudo usermod -a -G some-app-group deployhq
```

Replace `some-app-group` with your application group (typically `tomcat` or similar).

3.  **Configure a server:** In DeployHQ, go to **Servers** > **New Server**.
    -   **Server name:** Choose a recognizable name.
    -   **Protocol:** Select SSH.
    -   **Hostname:** Enter your server's IP address.
    -   **Username:** Enter `deployhq`.
    -   **Authentication:** Use SSH key. Run the following commands on your server:

```bash
su - deployhq
mkdir ~/.ssh
chmod 700 ~/.ssh
nano ~/.ssh/authorized_keys
```

Paste DeployHQ's public key, then press `Ctrl + X`,  `y`, and `Enter` to save.

```bash
chmod 600 ~/.ssh/authorized_keys
```

-   **Deployment Path:** Set this to your application directory (e.g.,  `/var/www/myapp`).
-   **Zero-downtime deployments:** Enable for seamless transitions during deployment.
    -   This creates a path like `/var/www/myapp/current` for application files. Update your web server configuration accordingly.
-   **Environment:** Set to `production`.
-   **Automatic deployments:** Enable for automated deployments on pushes.

4.  **Add a config file (Optional):** DeployHQ allows uploading configuration files without storing them in the repository. This is useful for sensitive files like `.env`.
    
    -   Go to **Config Files** and click **New Config File**.
    -   Paste the contents of your `.env.example` file into the config file content field.
5.  **Set up SSH commands:** In DeployHQ, navigate to **SSH Commands** and click **New SSH Command**. Create the following commands:
    
- **Install Dependencies:**
        
```bash
cd %path% && mvn clean install
```

- **Build Application:**
        
```bash
cd %path% && mvn package
```

- **Copy Artifact:** (Assuming a WAR file is generated)
        
```bash
cp %path%/target/*.war /var/lib/tomcat/webapps/yourapp.war
```
        
Replace `/var/lib/tomcat/webapps/yourapp.war` with your actual deployment path.
-  **Restart Tomcat:** (assuming a systemd service)
        
```bash
sudo systemctl restart tomcat
```
Adjust the command based on your specific service management system.

**Deployment:**

Click **Deploy Project** in the DeployHQ header. Select the server and desired revisions. Once confirmed, click **Deploy** to initiate the deployment process.

**Additional Resources:**

If you've got any other projects you'd like to automate deployments for, we've written lots of [guides for deploying the most popular application frameworks and content management systems](/guides).