mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 07:15:49 +00:00
chore: keep docker compose dependency with test scope.
This commit is contained in:
parent
68dfdddd4d
commit
5aedb47310
4 changed files with 14 additions and 25 deletions
9
pom.xml
9
pom.xml
|
@ -68,10 +68,6 @@
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-docker-compose</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Databases - Uses H2 by default -->
|
<!-- Databases - Uses H2 by default -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -122,6 +118,11 @@
|
||||||
<artifactId>spring-boot-testcontainers</artifactId>
|
<artifactId>spring-boot-testcontainers</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-docker-compose</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.testcontainers</groupId>
|
<groupId>org.testcontainers</groupId>
|
||||||
<artifactId>junit-jupiter</artifactId>
|
<artifactId>junit-jupiter</artifactId>
|
||||||
|
|
|
@ -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:
|
You only need to pass the Spring Boot profile at the time of running the application:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./mvnw spring-boot:run -Dspring-boot.run.profiles=mysql
|
./mvnw spring-boot:test-run -Dstart-class=org.springframework.samples.petclinic.MysqlTestApplication
|
||||||
```
|
```
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./mvnw spring-boot:run -Dspring-boot.run.profiles=postgres
|
./mvnw spring-boot:test-run -Dstart-class=org.springframework.samples.petclinic.PostgresIntegrationTests
|
||||||
```
|
```
|
||||||
|
|
||||||
## Test Applications
|
## Test Applications
|
||||||
|
|
|
@ -16,12 +16,8 @@
|
||||||
|
|
||||||
package org.springframework.samples.petclinic;
|
package org.springframework.samples.petclinic;
|
||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.Profile;
|
|
||||||
import org.testcontainers.containers.MySQLContainer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PetClinic Spring Boot Application.
|
* PetClinic Spring Boot Application.
|
||||||
|
@ -32,15 +28,10 @@ import org.testcontainers.containers.MySQLContainer;
|
||||||
@Configuration
|
@Configuration
|
||||||
public class MysqlTestApplication {
|
public class MysqlTestApplication {
|
||||||
|
|
||||||
@ServiceConnection
|
|
||||||
@Profile("mysql")
|
|
||||||
@Bean
|
|
||||||
static MySQLContainer<?> container() {
|
|
||||||
return new MySQLContainer<>("mysql:8.2");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(PetClinicApplication.class, "--spring.profiles.active=mysql");
|
new SpringApplicationBuilder(PetClinicApplication.class) //
|
||||||
|
.profiles("mysql") //
|
||||||
|
.run(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,9 +70,6 @@ public class PostgresIntegrationTests {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new SpringApplicationBuilder(PetClinicApplication.class) //
|
new SpringApplicationBuilder(PetClinicApplication.class) //
|
||||||
.profiles("postgres") //
|
.profiles("postgres") //
|
||||||
.properties( //
|
|
||||||
"spring.docker.compose.profiles.active=postgres" //
|
|
||||||
) //
|
|
||||||
.listeners(new PropertiesLogger()) //
|
.listeners(new PropertiesLogger()) //
|
||||||
.run(args);
|
.run(args);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue