diff --git a/pom.xml b/pom.xml index 8cf4db093..cf47f8aa6 100644 --- a/pom.xml +++ b/pom.xml @@ -68,10 +68,6 @@ spring-boot-starter-test test - - org.springframework.boot - spring-boot-docker-compose - @@ -122,6 +118,11 @@ spring-boot-testcontainers test + + org.springframework.boot + spring-boot-docker-compose + test + org.testcontainers junit-jupiter @@ -219,7 +220,7 @@ spring-boot-maven-plugin - build-info @@ -377,7 +378,7 @@ - org.eclipse.m2e @@ -435,4 +436,4 @@ - + \ No newline at end of file diff --git a/readme.md b/readme.md index 03cfcf636..f290a4169 100644 --- a/readme.md +++ b/readme.md @@ -52,13 +52,13 @@ A similar setup is provided for MySQL and PostgreSQL if a persistent database co You only need to pass the Spring Boot profile at the time of running the application: ```bash -./mvnw spring-boot:run -Dspring-boot.run.profiles=mysql +./mvnw spring-boot:test-run -Dstart-class=org.springframework.samples.petclinic.MysqlTestApplication ``` or ```bash -./mvnw spring-boot:run -Dspring-boot.run.profiles=postgres +./mvnw spring-boot:test-run -Dstart-class=org.springframework.samples.petclinic.PostgresIntegrationTests ``` ## Test Applications diff --git a/src/test/java/org/springframework/samples/petclinic/MysqlTestApplication.java b/src/test/java/org/springframework/samples/petclinic/MysqlTestApplication.java index a3ee84bb0..76adefa75 100644 --- a/src/test/java/org/springframework/samples/petclinic/MysqlTestApplication.java +++ b/src/test/java/org/springframework/samples/petclinic/MysqlTestApplication.java @@ -16,12 +16,8 @@ package org.springframework.samples.petclinic; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.testcontainers.service.connection.ServiceConnection; -import org.springframework.context.annotation.Bean; +import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.testcontainers.containers.MySQLContainer; /** * PetClinic Spring Boot Application. @@ -32,15 +28,10 @@ import org.testcontainers.containers.MySQLContainer; @Configuration public class MysqlTestApplication { - @ServiceConnection - @Profile("mysql") - @Bean - static MySQLContainer container() { - return new MySQLContainer<>("mysql:8.2"); - } - public static void main(String[] args) { - SpringApplication.run(PetClinicApplication.class, "--spring.profiles.active=mysql"); + new SpringApplicationBuilder(PetClinicApplication.class) // + .profiles("mysql") // + .run(args); } } diff --git a/src/test/java/org/springframework/samples/petclinic/PostgresIntegrationTests.java b/src/test/java/org/springframework/samples/petclinic/PostgresIntegrationTests.java index 18945a570..c4ca937c4 100644 --- a/src/test/java/org/springframework/samples/petclinic/PostgresIntegrationTests.java +++ b/src/test/java/org/springframework/samples/petclinic/PostgresIntegrationTests.java @@ -70,9 +70,6 @@ public class PostgresIntegrationTests { public static void main(String[] args) { new SpringApplicationBuilder(PetClinicApplication.class) // .profiles("postgres") // - .properties( // - "spring.docker.compose.profiles.active=postgres" // - ) // .listeners(new PropertiesLogger()) // .run(args); }