DEV Community

Salad Lam
Salad Lam

Posted on

Spring WebFlux example application: notice board

Objective

I wrote this application to explain the mechanism of different components of the Spring framework.

Function

  • Display notice on stated time
  • Approval before display
  • Multi language UI

Main component used

  • Project Reactor 3.7.X
  • Spring Boot 3.4.X
  • Spring WebFlux 6.2.X with thymeleaf 3.1.X
  • Spring Security 6.4.X
  • Spring R2DBC 6.2.X
  • Dozer 7.0.X
  • netty 4.1.X

Database

By default, data is stored in an embedded H2 database. Schema and data is imported when the application starts and all data will be lost after application shutdown.

MySQL database is also supported. In order to switch to MySQL database, first to modify the following properties located in application.properties file.

spring.r2dbc.url=r2dbc:mysql://localhost:3306/database-name
spring.r2dbc.username=root
spring.r2dbc.password=password
Enter fullscreen mode Exit fullscreen mode

Then deactivate 'db-h2' and activate 'db-mysql' Maven profiles when starting the application. And activate 'init-db' profiles also when starting the application at the first time.

Prerequisite

  • Java SE Development Kit 17 or above
  • Internet connection

Compile and run

Apache Maven wrapper is included, no additional package manager is necessary.

Compile (On Microsoft Windows)

mvnw package
Enter fullscreen mode Exit fullscreen mode

Run (On Microsoft Windows)

mvnw spring-boot:run
Enter fullscreen mode Exit fullscreen mode

Press Ctrl+C to stop.

Maven profiles

ID Activated by default Function
db-h2 Yes Using embedded H2 database
db-mysql No Using MySQL database
init-db Yes Import schema and initial data into database

Account

Username Password Authorities
user1 user1 USER
user2 user2 USER
admin admin USER, ADMIN

Source code

You may download source code from here.

Warp.dev image

Warp is the highest-rated coding agent—proven by benchmarks.

Warp outperforms every other coding agent on the market, and gives you full control over which model you use. Get started now for free, or upgrade and unlock 2.5x AI credits on Warp's paid plans.

Download Warp

Top comments (0)

Feature flag article image

Create a feature flag in your IDE in 5 minutes with LaunchDarkly’s MCP server ⏰

How to create, evaluate, and modify flags from within your IDE or AI client using natural language with LaunchDarkly's new MCP server. Follow along with this tutorial for step by step instructions.

Read full post

👋 Kindness is contagious

Explore this insightful write-up embraced by the inclusive DEV Community. Tech enthusiasts of all skill levels can contribute insights and expand our shared knowledge.

Spreading a simple "thank you" uplifts creators—let them know your thoughts in the discussion below!

At DEV, collaborative learning fuels growth and forges stronger connections. If this piece resonated with you, a brief note of thanks goes a long way.

Okay