-
Notifications
You must be signed in to change notification settings - Fork 40.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify documentation on importing Testcontainer declarations and using @ServiceConnection or @DynamicPropertySource #35629
Comments
Use |
Thank you for the quick response. You're correct. Adding The same relates to declaring containers as Spring beans. Here's an example from the documentation: @TestConfiguration(proxyBeanMethods = false)
public class MyContainersConfiguration {
@Bean
public MongoDBContainer monogDbContainer(DynamicPropertyRegistry properties) {
MongoDBContainer container = new MongoDBContainer("mongo:5.0");
properties.add("spring.data.mongodb.host", container::getHost);
properties.add("spring.data.mongodb.port", container::getFirstMappedPort);
return container;
}
} The documentation states that "A typical configuration would look like this". However Spring Boot fails to use it because it doesn't have |
Are you using it at development time just like the docs state? If no, keep using @DynamicPropertySource
static void properties(DynamicPropertyRegistry registry) {
registry.add("spring.data.mongodb.host", container::getHost);
registry.add("spring.data.mongodb.port", container::getFirstMappedPort);
} I think there is a confusion about the different usage |
In the docs, we don't know how That said, this has caused some confusion before so we probably need to do something here, I'm just not quite sure what. /cc @quaff |
@wilkinsona I think we should add |
Hi
We tried to use Spring Boot & TestContainers integration added in Spring Boot 3.1.0.
We used example from the reference documentation:
So we created an interface with our container declaration:
Then we created class-configuration:
and finally our integration test:
However our test failed with exception:
The text was updated successfully, but these errors were encountered: