Skip to content

Commit

Permalink
Reverse the tip for importing testcontainers declarations
Browse files Browse the repository at this point in the history
They now use `@ServiceConnection` by default.

Closes gh-35629
  • Loading branch information
mhalbritter committed Nov 13, 2023
1 parent 5a3e588 commit 9334840
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ To do so, add the `@ImportTestcontainers` annotation to your test configuration

include::code:MyContainersConfiguration[]

TIP: You can use the `@ServiceConnection` annotation on `Container` fields to establish service connections.
You can also add <<features#features.testing.testcontainers.dynamic-properties,`@DynamicPropertySource` annotated methods>> to your declaration class.
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.



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@
import org.testcontainers.containers.Neo4jContainer;
import org.testcontainers.junit.jupiter.Container;

import org.springframework.boot.testcontainers.service.connection.ServiceConnection;

public interface MyContainers {

@Container
@ServiceConnection
MongoDBContainer mongoContainer = new MongoDBContainer("mongo:5.0");

@Container
@ServiceConnection
Neo4jContainer<?> neo4jContainer = new Neo4jContainer<>("neo4j:5");

}

0 comments on commit 9334840

Please sign in to comment.