Skip to content

Java Spring Boot with Kafka example project for TechEule.com

Notifications You must be signed in to change notification settings

techeule/te-java-springboot-2-kafka

Repository files navigation

Java Spring Boot with Kafka example project for TechEule.com

All provided paths in this file are relative to the root-folder of this git-repository.

At TechEule.com you can find more info about this repository.

Code

The Avro-Schemas are located at: src/main/resources/avro-schemas/

Note

First, you have to compile this project using maven because the AVRO-classes are generated from the AVRO-Schema at src/main/resources/avro-schemas using the org.apache.avro :: avro-maven-plugin

Requirements

  • JDK version 17 or newer
  • Maven 3.8 or newer
  • Docker
  • Docker Compose

How to set up the environment/infrastructure

Open the terminal

# navigate to environment/te-spring-kafka-docker
cd environment/te-spring-kafka-docker

# start the docker compose services
# the first time it will take several minutes to pull all needed docker images
docker-compose up -d

After the environment is booted you have to run the database migration. This project support both database systems MySQL and Postgresql, but not at the same time.

Flyway: MySQL/MariaDB

mvn -Dflyway.configFiles=src/main/flyway/flyway-mysql.properties flyway:migrate

Flyway: Postgresql

mvn -Dflyway.configFiles=src/main/flyway/flyway-postgresql.properties flyway:migrate

How to build and run the applicaton

Maven build

Here you have to decide which database system do you want to use.

MySQL

mvn clean package --activate-profiles mysql,-postgresql

Postgresql

mvn clean package --activate-profiles -mysql,postgresql

Application Start

Here you have to decide which database system do you want to use.

MySQL

Using Maven
mvn clean spring-boot:run --activate-profiles mysql,-postgresql -Dspring-boot.run.profiles=mysql 
Plain java
java -Dspring.profiles.active="mysql" -jar target/techeule-java-maven-template.jar 

Postgresql

Using Maven
mvn clean spring-boot:run --activate-profiles -mysql,postgresql -Dspring-boot.run.profiles=postgresql
Plain java
java -Dspring.profiles.active="postgresql" -jar target/techeule-java-maven-template.jar

Resources