diff --git a/README.md b/README.md index a28c6c2e..6262e8f5 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,21 @@ For example, using PostgreSQL: See the [docker-compose file](docker/docker-compose.yml) (profile: `postgres`) for a sample configuration with PostgreSQL. +The configuration for using MySql is similar but with an additional setting for the Hibernate naming strategy: + +``` +- spring.datasource.url=jdbc:mysql://db:3306/simple_monitor +- spring.datasource.username=root +- spring.datasource.password=zeebe +- spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver +- spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect +- spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl +``` + +* the MySql database driver is already bundled + +See the [docker-compose file](docker/docker-compose.yml) (profile: `mysql`) for a sample configuration with MySql. + ## Code of Conduct This project adheres to the Contributor Covenant [Code of diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 8b770cf4..56411446 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -65,6 +65,42 @@ services: profiles: - postgres + simple-monitor-mysql: + container_name: zeebe-simple-monitor-mysql + image: ghcr.io/camunda-community-hub/zeebe-simple-monitor:2.4.1 + environment: + - zeebe.client.broker.gateway-address=zeebe:26500 + - zeebe.client.worker.hazelcast.connection=zeebe:5701 + - spring.datasource.url=jdbc:mysql://mysql-zeebe-simple-monitor:3306/simple_monitor?createDatabaseIfNotExist=true + - spring.datasource.username=root + - spring.datasource.password=zeebe + - spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver + - spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect + - spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl + ports: + - "8082:8082" + depends_on: + - zeebe + - mysql-zeebe-simple-monitor + networks: + - zeebe_network + profiles: + - mysql + + mysql-zeebe-simple-monitor: + image: mysql:8 + restart: always + environment: + MYSQL_ROOT_PASSWORD: zeebe + volumes: + - mysql-zeebe-simple-monitor-data:/var/lib/mysql + networks: + - zeebe_network + profiles: + - mysql + volumes: postgres-zeebe-simple-monitor-data: driver: local + mysql-zeebe-simple-monitor-data: + driver: local diff --git a/pom.xml b/pom.xml index 4367edc6..8de13fd2 100644 --- a/pom.xml +++ b/pom.xml @@ -140,6 +140,11 @@ postgresql + + mysql + mysql-connector-java + + @@ -201,6 +206,13 @@ test + + org.testcontainers + mysql + 1.17.3 + test + + org.springframework.boot diff --git a/src/test/java/io/zeebe/monitor/repository/ZeebeApplicationMysqlTest.java b/src/test/java/io/zeebe/monitor/repository/ZeebeApplicationMysqlTest.java new file mode 100644 index 00000000..70248535 --- /dev/null +++ b/src/test/java/io/zeebe/monitor/repository/ZeebeApplicationMysqlTest.java @@ -0,0 +1,28 @@ +package io.zeebe.monitor.repository; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.support.AnnotationConfigContextLoader; +import org.springframework.transaction.annotation.Transactional; + +import static org.assertj.core.api.Assertions.assertThat; + +@SpringBootTest +@ContextConfiguration( + classes = {TestContextJpaConfiguration.class}, + loader = AnnotationConfigContextLoader.class) +@Transactional +@ActiveProfiles({"mysql-docker", "application-junittest.yaml"}) +public class ZeebeApplicationMysqlTest { + + @Autowired + private VariableRepository variableRepository; + + @Test + void setup_of_mysql_should_work() { + assertThat(variableRepository).isNotNull(); + } +} diff --git a/src/test/resources/application-mysql-docker.yaml b/src/test/resources/application-mysql-docker.yaml new file mode 100644 index 00000000..77095fd5 --- /dev/null +++ b/src/test/resources/application-mysql-docker.yaml @@ -0,0 +1,13 @@ +spring: + datasource: + url: jdbc:tc:mysql:latest:///test + username: test + password: test + jpa: + properties: + hibernate: + dialect: org.hibernate.dialect.MySQL8Dialect + naming: + physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl + hibernate: + ddl-auto: create