Spring WebFlux example application: notice board
Salad Lam

Salad Lam @saladlam

Location:
London
Joined:
May 15, 2023

Spring WebFlux example application: notice board

Publish Date: May 17
0 0

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.

Comments 0 total

    Add comment