ServiceConnection class final

Marks a Container field whose connection properties become properties of the test's context: PostgresContainer sets spring.datasource.url, username and password, KeycloakContainer the issuer URIs.

The properties are a dynamic property source, which wins over every other source (properties:, the config files, the environment); a @DynamicPropertySource method runs after them and can still change one. The container must implement ServiceConnectionProperties; for any other, register its properties in a @DynamicPropertySource method.

@Container()
@ServiceConnection()
static final postgres = PostgresContainer('postgres:17-alpine');

Spring Boot (Java): @ServiceConnection on a @Container field, which registers a ConnectionDetails bean from the container.

Constructors

ServiceConnection()
Marks the field.
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited