Spring Boot backend for a real-time chat application using STOMP over WebSocket, JWT auth, and MySQL.
- Set environment variables (required):
DB_URL(optional, defaults to localchat_app)DB_USERNAMEDB_PASSWORDJWT_SECRET(32+ characters)JWT_EXP_MINUTES(optional, default 60)
- Optional local file: copy
src/main/resources/application.example.ymltosrc/main/resources/application-local.ymland run withSPRING_PROFILES_ACTIVE=local.
PowerShell example:
$env:DB_URL="jdbc:mysql://localhost:3306/chat_app?useSSL=false&serverTimezone=UTC"
$env:DB_USERNAME="chat_user"
$env:DB_PASSWORD="change-me"
$env:JWT_SECRET="change-me-change-me-change-me-change"
$env:JWT_EXP_MINUTES="60"
mvn spring-boot:run
- POST
/api/auth/register - POST
/api/auth/login - GET
/api/messages/public?limit=50 - GET
/api/messages/private/{username}?limit=50
- Endpoint:
/ws - Public send:
/app/public.send - Public subscribe:
/topic/public - Private send:
/app/private.send - Private subscribe:
/user/queue/private
Clients should pass Authorization: Bearer <JWT> in the STOMP CONNECT headers.