---
title: "Deploy HTMX+Spring+Thymeleaf+MySQL"
description: "HTMX + Spring + Thymeleaf + MySQL. Full-stack server-rendered app."
category: "Starters"
url: https://railway.com/deploy/htmxspringthymeleafmysql
---

# Deploy HTMX+Spring+Thymeleaf+MySQL

HTMX + Spring + Thymeleaf + MySQL. Full-stack server-rendered app.

**[Deploy HTMX+Spring+Thymeleaf+MySQL on Railway](https://railway.com/template/htmxspringthymeleafmysql)**

- **Creator:** André Ahlert
- **Category:** Starters
- **Total deploys:** 1

## Template content

### MySQL https://devicons.railway.app/i/mysql.svg

- **Image:** mysql:9.4
- **Start command:** `docker-entrypoint.sh mysqld --innodb-use-native-aio=0 --disable-log-bin --performance_schema=0 --innodb-buffer-pool-size=1G`

### web https://raw.githubusercontent.com/atoolz/railway-htmx-java-spring-thymeleaf-mysql/master/assets/icon.png

- **Source:** https://github.com/atoolz/railway-htmx-java-spring-thymeleaf-mysql
- **Health check:** /health

## Documentation

# Deploy and Host HTMX+Spring+Thymeleaf+MySQL on Railway

**HTMX + Spring Boot + Thymeleaf + MySQL** is a server-rendered full-stack setup: Spring Boot serves HTML with Thymeleaf, HTMX updates fragments without a heavy SPA, and MySQL stores data through JPA. You ship one JVM service in Docker; Flyway runs SQL migrations at startup. Tailwind and HTMX load from a CDN, so there is no separate frontend build pipeline.

## About Hosting HTMX+Spring+Thymeleaf+MySQL on Railway

Hosting means running a **multi-stage Dockerfile** (Maven build, slim JRE runtime) as a **web** service and adding Railway’s **MySQL** plugin. The app expects **`DATABASE_URL`** as a **`mysql://user:pass@host:3306/database`** string; on Railway, set **`DATABASE_URL="${{MySQL.MYSQL_URL}}"`** on the web service so it uses the plugin’s private-network URL. **`RailwayDataSourceConfig`** parses that URL into a HikariCP **`jdbc:mysql://`** datasource and enables SSL for non-local hosts. **Flyway** applies migrations (for example `V1__todos.sql`) before the app accepts traffic. Configure the service health check to **`GET /health`**, which returns JSON and verifies the database. **`PORT`** defaults to **`8080`**. Thymeleaf templates and HTMX attributes live in the repo; no Node bundler is required for the demo UI.

## Common Use Cases

- **Internal tools and ops dashboards** — partial page updates with `hx-post` / `hx-patch` / `hx-delete` without maintaining a separate API + SPA.
- **CRUD and form-heavy apps** — server validation and SSR-friendly flows while keeping the stack on Java and MySQL.
- **MVPs and teaching stacks** — one repo, one container, familiar Spring + SQL, easy to extend with Spring Security or more domains later.

## Dependencies for HTMX+Spring+Thymeleaf+MySQL Hosting

- **Railway MySQL** (or any MySQL-compatible **`mysql://`** URL exposed as **`DATABASE_URL`**).
- **Web service** built from this template’s **Dockerfile** at the repository root.

### Deployment Dependencies

- [HTMX](https://htmx.org/docs/)
- [Spring Boot](https://spring.io/projects/spring-boot)
- [Thymeleaf](https://www.thymeleaf.org/)
- [Flyway — MySQL](https://flywaydb.org/documentation/database/mysql)
- [Railway](https://railway.com/)

### Implementation Details

- On the **web** service: **`DATABASE_URL="${{MySQL.MYSQL_URL}}"`** (must start with **`mysql://`**).
- **Health check path:** **`/health`**.
- Example local run: `export DATABASE_URL="mysql://user:pass@127.0.0.1:3306/db"` then `mvn spring-boot:run`.
- **Thymeleaf fragments** under `templates/fragments/` are swapped by HTMX for the included todo demo.

## Why Deploy HTMX+Spring+Thymeleaf+MySQL on Railway?


Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying HTMX+Spring+Thymeleaf+MySQL on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


## Similar templates

- [open-excalidraw](https://railway.com/deploy/open-excalidraw) — Self-hostable collaborative drawing built on Excalidraw
- [caring-vibrancy](https://railway.com/deploy/caring-vibrancy) — Deploy and Host caring-vibrancy with Railway
- [Appsmith](https://railway.com/deploy/appsmith-1) — Low-code platform for internal tools, dashboards, and admin panels.

Open this page in a browser: https://railway.com/deploy/htmxspringthymeleafmysql
