-
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
SpringApplication.from(…).with(…) adds its sources to every context that's created #35873
Comments
The |
Hi, thanks for the speedy reply. Yes, I was about to create a sample project, but during the process I discovered the problem. It is due to the project using spring cloud kubernetes implementation 'org.springframework.cloud:spring-cloud-starter-kubernetes-client-config'
implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap' //Use bootstrap.yml to load configmap and secret The introduction of the bootstrap context from spring cloud for some reason prevents My guess is that @ConditionalOnClass(DynamicPropertyRegistry.class)
public class TestcontainersPropertySourceAutoConfiguration { As the bootstrap classpath doesn't include DynamicPropertyRegistry.class, the condition is failing |
Defining the bean in the bootstrap phase by using @Bean
DynamicPropertyRegistry dynamicPropertyRegistry(ConfigurableEnvironment environment) {
return TestcontainersPropertySource.attach(environment);
} doesn't work as there is then a conflict when the normal application context phase kicks in and tries to create a DynamicPropertyRegistry again, so failing
Does this just mean you cannot combine DynamicPropertyRegistry with spring cloud bootstrap? |
Using spring:
main:
allow-bean-definition-overriding: true allows the above to work, that is @TestConfiguration(proxyBeanMethods = false)
public class ContainersConfiguration {
@Bean
@Primary
DynamicPropertyRegistry dynamicPropertyRegistry(ConfigurableEnvironment environment) {
return TestcontainersPropertySource.attach(environment);
}
@Bean
public KeycloakContainer keycloakContainer(DynamicPropertyRegistry registry) {.... But this doesn't work, as the properties are lost some how, anyhow, I really can't see what else to try, except remove spring cloud bootstrap. |
AFAIK, there's no separation between the classes that are available to the bootstrap context and the classes that are available to the main context.
We might be able to suggest something if you provide the minimal sample that was requested above. |
thanks, here's a minimal : https://github.com/jbeaken/dynamic run
|
Thanks for the sample. The problem's caused by a bug in the new
This avoids the problem but comes at the cost of not being able to reuse the main method in your application's main code. |
Using Testcontainers at Development Time I have
with
Upon running
gradle bootTestRun
it throwsNo qualifying bean of type 'org.springframework.test.context.DynamicPropertyRegistry' available:
While reading the docs it suggests it is possible, when @Serviceconnection isn't supported
Does anyone know if dynamic properties are supported?
The text was updated successfully, but these errors were encountered: