A server-side rendered (SSR) Spring Boot application for managing teachers and users, built with Thymeleaf views, Spring Data JPA, Spring Security, and Flyway for database migrations.
This README covers the stack, entry points, how to run it locally, scripts, environment variables, tests, project structure, and license information.
- Language: Java 21 (Amazon Corretto toolchain via Gradle)
- Frameworks/Libraries:
- Spring Boot 3.5.x (Web, Thymeleaf, Validation)
- Spring Data JPA (Hibernate)
- Spring Security 6 (with Thymeleaf extras)
- Flyway (database migrations)
- Lombok (compile-time annotations)
- Database: MySQL 8+
- Build/Package Manager: Gradle (Wrapper included)
- Main class:
gr.aueb.cf.schoolapp.SchoolappApplication- Method:
public static void main(String[] args)launches Spring Boot.
- Method:
- Default active profile:
dev(configured insrc/main/resources/application.properties).
- Java 21 (the Gradle toolchain can auto-provision an Amazon Corretto 21 JDK on build)
- MySQL 8+ running and reachable
- Ports:
- Default server port is 8080 (can be changed via
server.port)
- Default server port is 8080 (can be changed via
Optional: Docker for local MySQL instance (example below).
Configuration is managed via Spring profiles and environment variables. Defaults for dev are defined in application-dev.properties.
Recognized environment variables (with dev defaults in parentheses):
SPRING_PROFILES_ACTIVE— active profile (default:devset inapplication.properties)MYSQL_HOST— MySQL host (default:localhost)MYSQL_PORT— MySQL port (default:3306)MYSQL_DB— database name (default:school9ssr)MYSQL_USER— database user (default:user9)MYSQL_PASSWORD— database password (default:12345)
Other relevant settings (profile-specific):
spring.jpa.hibernate.ddl-auto=validate(expects schema managed by Flyway)- Flyway is enabled in
dev(can be toggled withspring.flyway.enabled) spring.jpa.open-in-view=false(encourages fetch joins in services)- Thymeleaf cache disabled in
devfor faster view iteration
Profiles available:
dev— default for local development.staging— placeholder (currently minimal props).prod— placeholder (add production DB and tuning props here).
Activate a profile at runtime:
- JVM arg:
-Dspring.profiles.active=prod - or Spring arg:
--spring.profiles.active=prod - or environment variable:
SPRING_PROFILES_ACTIVE=prod
- Clone the repository.
- Start MySQL and create the database if it doesn’t exist (Flyway will manage schema):
- Database:
school9ssr(or setMYSQL_DB) - User:
user9with password12345(or adjustMYSQL_USER/MYSQL_PASSWORD)
- Database:
- Optionally, run MySQL with Docker:
- Linux/macOS PowerShell equivalent:
docker run --name mysql8 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=school9ssr -e MYSQL_USER=user9 -e MYSQL_PASSWORD=12345 -p 3306:3306 -d mysql:8
- Then export/set environment variables if you changed defaults.
- Linux/macOS PowerShell equivalent:
Using the Gradle Wrapper (recommended):
- Windows PowerShell:
- Development profile (default):
./gradlew.bat bootRun - Explicit profile:
./gradlew.bat bootRun --args="--spring.profiles.active=dev"
- Development profile (default):
- macOS/Linux:
- Development profile (default):
./gradlew bootRun - Explicit profile:
./gradlew bootRun --args="--spring.profiles.active=dev"
- Development profile (default):
Build an executable JAR:
- Windows:
./gradlew.bat clean bootJar - macOS/Linux:
./gradlew clean bootJar
Note: The resulting artifact is build/libs/schoolapp.jar (customized via bootJar.archiveFileName in build.gradle).
Run the JAR:
- Windows:
java -jar build\libs\schoolapp.jar --spring.profiles.active=prod - macOS/Linux:
java -jar build/libs/schoolapp.jar --spring.profiles.active=prod
Access the app:
- Default URL:
http://localhost:8080/ - Thymeleaf views are rendered on the server. Example pages include teachers listing, insert/edit forms, login page, etc.
./gradlew[.bat] bootRun— Run the application with hot reload (DevTools included as developmentOnly)./gradlew[.bat] test— Run tests (JUnit Platform)./gradlew[.bat] build— Build the project (runs tests)./gradlew[.bat] clean— Clean build outputs./gradlew[.bat] bootJar— Build the executable Spring Boot JAR
- Migration scripts live under
src/main/resources/db/migrationand run automatically on startup (when enabled). - Current migration files:
V1__initial_schema.sqlV2__insert_regions.sqlV3__alter_teachers_add_soft_delete_columns.sqlV4__teachers_soft_delete_indexes.sqlV5__create_users_roles_capabilities_indexes.sqlV6__insert_roles_capabilites.sql
- Location:
src/test/java - Example test suite:
gr.aueb.cf.schoolapp.SchoolappApplicationTests - Run:
./gradlew[.bat] test
src/main/java/gr/aueb/cf/schoolapp/SchoolappApplication.java— Spring Boot entry pointcontroller/— MVC controllers (e.g.,TeacherController,UserController,LoginController)service/— Service layer (TeacherService,UserService, etc.)repository/— Spring Data JPA repositoriesmodel/— JPA entities (e.g.,Teacher,User,Role,Capability,Region)authentication/— Security config and handlersdto/— Data Transfer Objectsvalidator/— Validation logic for formsmapper/— Mapping utilities
src/main/resources/templates/— Thymeleaf HTML templates (SSR views)static/— Static assets (CSS, images)db/migration/— Flyway migration scriptsapplication*.properties— Profile-based configuration
- Message bundles:
messages.properties,messages_el.properties
- Configured via
src/main/resources/logback-spring.xml - Log files under
./logs(e.g.,all.log,error.log,sql.log,tomcat.log, and dated rollovers)
- Spring Security is enabled. Login-related pages and handlers live under
authentication/andcontroller/. - Thymeleaf extra dialect for security:
thymeleaf-extras-springsecurity6.
- Verify DB connectivity and credentials (see env vars above).
- If schema validation fails (
ddl-auto=validate), ensure Flyway ran and the DB is empty/consistent. - Change server port via
server.portin the active profile properties or runtime arg.
No explicit license file is provided in this repository. Unless a license is added, all rights are reserved by the repository owner. If you need to use this code, please contact the owner or add an appropriate LICENSE file.