I am about to write unit testcase with junit5 for my spring integration project. But when i am running a sample testcase, i am getting an exception. the below given code is my sample testcase,
@SpringBootTest
class IntegrationUtilsTest {
@Test
@DisplayName("sample test")
void sample() {
Assert.assertTrue(true);
}
}
and I am getting the following log while running this test,
2020-12-08 18:06:45.780 DEBUG --- [ main] com.tngtech.archunit.ArchConfiguration : No configuration found in classpath at archunit.properties => Using default configuration
██╗ ██╗ ██╗ ████████╗ ███████╗ ██████╗ ████████╗ ████████╗ ███████╗
██║ ██║ ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
██║ ████████║ ██║ ███████╔╝ ╚█████╗ ██║ ██████╗ ███████╔╝
██╗ ██║ ██╔═══██║ ██║ ██╔════╝ ╚═══██╗ ██║ ██╔═══╝ ██╔══██║
╚██████╔╝ ██║ ██║ ████████╗ ██║ ██████╔╝ ██║ ████████╗ ██║ ╚██╗
╚═════╝ ╚═╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═╝
:: JHipster :: Running Spring Boot 2.2.7.RELEASE ::
:: https://www.jhipster.tech ::
2020-12-08 18:06:46.950 INFO 5036 --- [ main] c.m.a.i.service.IntegrationUtilsTest : No active profile set, falling back to default profiles: default
2020-12-08 18:06:50.330 DEBUG 5036 --- [ main] i.m.c.u.i.logging.InternalLoggerFactory : Using SLF4J as the default logging framework
2020-12-08 18:06:51.722 WARN 5036 --- [ main] .h.i.HttpRequestHandlingMessagingGateway : The 'requestPayloadType' attribute will have no relevance for one of the specified HTTP methods '[GET, HEAD, OPTIONS]'
2020-12-08 18:06:51.727 WARN 5036 --- [ main] .h.i.HttpRequestHandlingMessagingGateway : The 'requestPayloadType' attribute will have no relevance for one of the specified HTTP methods '[GET, HEAD, OPTIONS]'
2020-12-08 18:06:51.732 WARN 5036 --- [ main] .h.i.HttpRequestHandlingMessagingGateway : The 'requestPayloadType' attribute will have no relevance for one of the specified HTTP methods '[GET, HEAD, OPTIONS]'
2020-12-08 18:06:53.314 WARN 5036 --- [ main] ockingLoadBalancerClientRibbonWarnLogger : You already have RibbonLoadBalancerClient on your classpath. It will be used by default. As Spring Cloud Ribbon is in maintenance mode. We recommend switching to BlockingLoadBalancerClient instead. In order to use it, set the value of `spring.cloud.loadbalancer.ribbon.enabled` to `false` or remove spring-cloud-starter-netflix-ribbon from your project.
2020-12-08 18:06:53.685 INFO 5036 --- [ main] c.m.a.i.service.IntegrationUtilsTest : Started IntegrationUtilsTest in 7.545 seconds (JVM running for 8.789)
2020-12-08 18:06:53.710 DEBUG 5036 --- [ main] reactor.util.Loggers$LoggerFactory : Using Slf4j logging framework
2020-12-08 18:06:53.712 DEBUG 5036 --- [ main] reactor.core.publisher.Hooks : Hooking onLastOperator: org.springframework.security.core.context.SecurityContext
2020-12-08 18:06:53.758 DEBUG 5036 --- [ main] reactor.core.publisher.Hooks : Reset onLastOperator: org.springframework.security.core.context.SecurityContext
2020-12-08 18:06:54.118 WARN 5036 --- [extShutdownHook] i.m.c.i.d.DropwizardMeterRegistry : Failed to apply the value function for the gauge 'spring.integration.channels'. Note that subsequent logs will be logged at debug level.
org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'nullChannel': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:212)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:623)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:611)
at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1242)
at org.springframework.integration.config.IntegrationManagementConfigurer.lambda$registerComponentGauges$1(IntegrationManagementConfigurer.java:444)
at io.micrometer.core.instrument.dropwizard.DropwizardMeterRegistry.lambda$newGauge$0(DropwizardMeterRegistry.java:87)
at com.codahale.metrics.Slf4jReporter.logGauge(Slf4jReporter.java:342)
at com.codahale.metrics.Slf4jReporter.report(Slf4jReporter.java:258)
at com.codahale.metrics.ScheduledReporter.report(ScheduledReporter.java:253)
at com.codahale.metrics.ScheduledReporter.stop(ScheduledReporter.java:200)
at com.codahale.metrics.ScheduledReporter.close(ScheduledReporter.java:245)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:339)
at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:273)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:579)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:551)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:1091)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:512)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:1084)
at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1060)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1029)
at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:948)
Can anyone help me understand this. why this BeanCreationNotAllowedException ?
UPDATE 1
I added the class and created the spring.factories file. But I am not able to start the application. I am getting the following error.
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of method metricsWebMvcConfigurer in org.springframework.boot.actuate.autoconfigure.metrics.web.servlet.WebMvcMetricsAutoConfiguration required a single bean, but 2 were found:
- prometheusMeterRegistry: defined by method 'prometheusMeterRegistry' in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.class]
- consoleLoggingRegistry: defined by method 'consoleLoggingRegistry' in class path resource [io/github/jhipster/config/metric/JHipsterLoggingMetricsExportConfiguration.class]
Action:
Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed.
Which bean i should use and how to make it qualified for autowiring?