mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Merge branch '3.1.x'
Closes gh-38337
This commit is contained in:
commit
580d569ed0
@ -76,8 +76,7 @@ To do so, add the `@ImportTestcontainers` annotation to your test configuration
|
|||||||
|
|
||||||
include::code:MyContainersConfiguration[]
|
include::code:MyContainersConfiguration[]
|
||||||
|
|
||||||
TIP: You can use the `@ServiceConnection` annotation on `Container` fields to establish service connections.
|
TIP: If you don't intend to use the <<features#features.testing.testcontainers.service-connections, service connections feature>> but want to use <<features#features.testing.testcontainers.dynamic-properties, `@DynamicPropertySource`>> instead, remove the `@ServiceConnection` annotation from the `Container` fields.
|
||||||
You can also add <<features#features.testing.testcontainers.dynamic-properties,`@DynamicPropertySource` annotated methods>> to your declaration class.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,12 +20,16 @@ import org.testcontainers.containers.MongoDBContainer;
|
|||||||
import org.testcontainers.containers.Neo4jContainer;
|
import org.testcontainers.containers.Neo4jContainer;
|
||||||
import org.testcontainers.junit.jupiter.Container;
|
import org.testcontainers.junit.jupiter.Container;
|
||||||
|
|
||||||
|
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||||
|
|
||||||
public interface MyContainers {
|
public interface MyContainers {
|
||||||
|
|
||||||
@Container
|
@Container
|
||||||
|
@ServiceConnection
|
||||||
MongoDBContainer mongoContainer = new MongoDBContainer("mongo:5.0");
|
MongoDBContainer mongoContainer = new MongoDBContainer("mongo:5.0");
|
||||||
|
|
||||||
@Container
|
@Container
|
||||||
|
@ServiceConnection
|
||||||
Neo4jContainer<?> neo4jContainer = new Neo4jContainer<>("neo4j:5");
|
Neo4jContainer<?> neo4jContainer = new Neo4jContainer<>("neo4j:5");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user