This tutorial walks you through the steps of creating an Email Verification web application Example with Spring Boot, MySQL and Amazon AWS SES

What you'll build

  • Email Verification Form

  • Send verification email through Amazon SES

  • Verify email service

What you'll need

Stack

  • Docker
  • Spring Boot
  • Java Mail API
  • Spring Data JPA
  • MySQL
  • NGINX
  • Maven

Init project structure and dependencies

Project structure

├── src
│   └── main
│       ├── java
│       │   └── com
│       │       └── hellokoding
│       │           └── account
│       │               ├── model
│       │               │   ├── MailProperties.java
│       │               │   ├── User.java
│       │               │   ├── VerificationForm.java
│       │               │   └── VerificationToken.java
│       │               ├── repository
│       │               │   ├── UserRepository.java
│       │               │   └── VerificationTokenRepository.java
│       │               ├── service
│       │               │   ├── SendingMailService.java
│       │               │   └── VerificationTokenService.java
│       │               ├── web
│       │               │   └── AccountController.java
│       │               └── WebApplication.java
│       └── resources
│           ├── static
│           │   ├── css
│           │   │   └── main.css
│           │   └── js
│           │       └── main.js
│           ├── templates
│           │   ├── email-verification.ftl
│           │   └── verification-form.ftl
│           └── application.properties
├── Dockerfile
├── docker-compose.yaml
└── pom.xml

Application dependencies


Define JPA Entities and Repositories

JPA Entities



JPA Repositories



Define Services



Define Controllers and View Templates

Controllers


FreeMarker View template



Config and Run

Application Configuration



Run with Docker

Prepare Dockerfile for Java/Spring Boot application and docker-compose.yml for MySQL Server



Type the below command at the project root directory, make sure your local Docker is running

docker-compose up

Run with JDK/OpenJDK, Maven and MySQL Server local

  • On application.properties, update data source user name + password to your local configs, update data source url hk-mysql to localhost

  • Then type this command at the project root directory mvn clean spring-boot:run

Test

Open your browser and access to http://localhost:8080

Source code

https://github.com/hellokoding/hellokoding-courses/tree/master/springboot-examples/springboot-email-verification-mysql