Reputation: 61
I get this error when trying to run Spring Application:
WARN Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'connectionManager' defined in URL [jar:file:/F:/views/g/main_1v/Qstreams/provision2/QResultsDomain/QResultsDomain/PostProcessingManagement/build/libs/QResultsDomain-PostProcessingManagement-2022.1.22708.jar!/amat/results_domain/post_processing_management/connection/ConnectionManager.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'amat.results_domain.core.configuration.ResultsDomainConfigurationService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {} - AnnotationConfigServletWebServerApplicationContext.refresh
This is my main class:
@SpringBootApplication
@Import(DevStandaloneConfiguration.class)
public class DevStandaloneApplication {
public static void main(String[] args) {
SpringApplication app = new SpringApplication(DevStandaloneApplication.class);
app.setDefaultProperties(Collections.singletonMap("spring.profiles.active", "standAlone"));
ConfigurableApplicationContext applicationContext = app.run(args);
applicationContext.registerShutdownHook();
}
}
And here are my two implementations for the ResultsDomainConfigurationService interface:
@Service
@Profile("standAlone")
public class MockResultsDomainConfigurationService implements ResultsDomainConfigurationService {...}
@Service
@Profile("production")
public class ResultsDomainConfigurationServiceImpl implements ResultsDomainConfigurationService {...}
Here is the profile Spring recognize: The following 1 profile is active: "standAlone"
Why doesn't Spring use the implementation with the @Profile("standAlone")
annotation?
Thanks
Upvotes: 0
Views: 22