diff --git a/nrich-webmvc-spring-boot-starter/build.gradle b/nrich-webmvc-spring-boot-starter/build.gradle index e1095eb2b..153bff54e 100644 --- a/nrich-webmvc-spring-boot-starter/build.gradle +++ b/nrich-webmvc-spring-boot-starter/build.gradle @@ -7,14 +7,15 @@ dependencies { annotationProcessor "org.projectlombok:lombok" compileOnly "org.projectlombok:lombok" - implementation project(":nrich-logging") implementation project(":nrich-spring-boot") implementation project(":nrich-webmvc") + runtimeOnly project(":nrich-logging-spring-boot-starter") runtimeOnly project(":nrich-notification-spring-boot-starter") implementation "org.springframework.boot:spring-boot-autoconfigure" + testImplementation project(":nrich-logging-spring-boot-starter") testImplementation project(":nrich-notification-spring-boot-starter") testRuntimeOnly "ch.qos.logback:logback-classic" diff --git a/nrich-webmvc-spring-boot-starter/src/main/java/net/croz/nrich/webmvc/starter/configuration/NrichWebMvcAutoConfiguration.java b/nrich-webmvc-spring-boot-starter/src/main/java/net/croz/nrich/webmvc/starter/configuration/NrichWebMvcAutoConfiguration.java index 15fec0126..7b1e9b555 100644 --- a/nrich-webmvc-spring-boot-starter/src/main/java/net/croz/nrich/webmvc/starter/configuration/NrichWebMvcAutoConfiguration.java +++ b/nrich-webmvc-spring-boot-starter/src/main/java/net/croz/nrich/webmvc/starter/configuration/NrichWebMvcAutoConfiguration.java @@ -1,7 +1,6 @@ package net.croz.nrich.webmvc.starter.configuration; import net.croz.nrich.logging.api.service.LoggingService; -import net.croz.nrich.logging.service.Slf4jLoggingService; import net.croz.nrich.notification.api.service.BaseNotificationResponseService; import net.croz.nrich.springboot.condition.ConditionalOnPropertyNotEmpty; import net.croz.nrich.webmvc.advice.ControllerEditorRegistrationAdvice; @@ -51,12 +50,6 @@ public ExceptionHttpStatusResolverService exceptionHttpStatusResolverService(Mes return new MessageSourceExceptionHttpStatusResolverService(messageSource); } - @ConditionalOnMissingBean - @Bean - public LoggingService loggingService(MessageSource messageSource) { - return new Slf4jLoggingService(messageSource); - } - @ConditionalOnProperty(name = "nrich.webmvc.controller-advice-enabled", havingValue = "true", matchIfMissing = true) @Bean public NotificationErrorHandlingRestControllerAdvice notificationRestControllerAdvice(NrichWebMvcProperties webMvcProperties, BaseNotificationResponseService notificationResponseService, diff --git a/nrich-webmvc-spring-boot-starter/src/test/java/net/croz/nrich/webmvc/starter/configuration/NrichWebMvcAutoConfigurationTest.java b/nrich-webmvc-spring-boot-starter/src/test/java/net/croz/nrich/webmvc/starter/configuration/NrichWebMvcAutoConfigurationTest.java index df3d81f53..97dd95d1c 100644 --- a/nrich-webmvc-spring-boot-starter/src/test/java/net/croz/nrich/webmvc/starter/configuration/NrichWebMvcAutoConfigurationTest.java +++ b/nrich-webmvc-spring-boot-starter/src/test/java/net/croz/nrich/webmvc/starter/configuration/NrichWebMvcAutoConfigurationTest.java @@ -1,6 +1,7 @@ package net.croz.nrich.webmvc.starter.configuration; import net.croz.nrich.logging.api.service.LoggingService; +import net.croz.nrich.logging.starter.configuration.NrichLoggingAutoConfiguration; import net.croz.nrich.notification.starter.configuration.NrichNotificationAutoConfiguration; import net.croz.nrich.webmvc.advice.ControllerEditorRegistrationAdvice; import net.croz.nrich.webmvc.advice.NotificationErrorHandlingRestControllerAdvice; @@ -18,7 +19,7 @@ class NrichWebMvcAutoConfigurationTest { private final WebApplicationContextRunner webApplicationContextRunner = new WebApplicationContextRunner() - .withConfiguration(AutoConfigurations.of(NrichNotificationAutoConfiguration.class, NrichWebMvcAutoConfiguration.class)); + .withConfiguration(AutoConfigurations.of(NrichLoggingAutoConfiguration.class, NrichNotificationAutoConfiguration.class, NrichWebMvcAutoConfiguration.class)); @Test void shouldConfigureDefaultConfiguration() { @@ -37,18 +38,16 @@ void shouldConfigureDefaultConfiguration() { @Test void shouldAddConstrainedLocaleResolverWhenAllowedLocaleListIsNotEmpty() { // expect - webApplicationContextRunner.withPropertyValues("nrich.webmvc.allowed-locale-list=hr,en") - .withBean(ResourceBundleMessageSource.class).run(context -> - assertThat(context).hasSingleBean(ConstrainedSessionLocaleResolver.class) - ); + webApplicationContextRunner.withPropertyValues("nrich.webmvc.allowed-locale-list=hr,en").withBean(ResourceBundleMessageSource.class).run(context -> + assertThat(context).hasSingleBean(ConstrainedSessionLocaleResolver.class) + ); } @Test void shouldNotAddAdviceWhenItsDisabled() { // expect - webApplicationContextRunner.withPropertyValues("nrich.webmvc.controller-advice-enabled=false") - .withBean(ResourceBundleMessageSource.class).run(context -> - assertThat(context).doesNotHaveBean(NotificationErrorHandlingRestControllerAdvice.class) - ); + webApplicationContextRunner.withPropertyValues("nrich.webmvc.controller-advice-enabled=false").withBean(ResourceBundleMessageSource.class).run(context -> + assertThat(context).doesNotHaveBean(NotificationErrorHandlingRestControllerAdvice.class) + ); } }