diff --git a/pom.xml b/pom.xml index e5bdbf4..fcb0ad1 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,7 @@ 17 3.2.1 - 5.0.4 + 5.0.5 2.5.3 1.13.0 @@ -205,7 +205,7 @@ org.jacoco jacoco-maven-plugin - 0.8.8 + 0.8.12 diff --git a/src/main/java/io/beanmapper/autoconfigure/BeanMapperAutoConfig.java b/src/main/java/io/beanmapper/autoconfigure/BeanMapperAutoConfig.java index 02935ae..8dcdba7 100644 --- a/src/main/java/io/beanmapper/autoconfigure/BeanMapperAutoConfig.java +++ b/src/main/java/io/beanmapper/autoconfigure/BeanMapperAutoConfig.java @@ -13,6 +13,7 @@ import io.beanmapper.spring.web.converter.StructuredJsonMessageConverter; import jakarta.annotation.Nonnull; import jakarta.annotation.PostConstruct; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanInstantiationException; @@ -28,6 +29,7 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.EnableAspectJAutoProxy; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; import org.springframework.util.ClassUtils; import org.springframework.web.method.support.HandlerMethodArgumentResolver; @@ -46,6 +48,7 @@ * will be added to the Spring MVC context. */ @Configuration +@EnableAspectJAutoProxy @AutoConfigureAfter(WebMvcAutoConfiguration.class) @EnableConfigurationProperties(BeanMapperProperties.class) public class BeanMapperAutoConfig { @@ -72,7 +75,7 @@ private void initApplicationScanner() { /** * Creates a {@link BeanMapper} bean with spring-data-jpa defaults. - * If a {@link BeanMapperBuilderCustomizer} bean is found, uses this to + * If a {@link BeanMapperBuilderCustomizer} bean is found, uses this to * customize the builder before the {@link BeanMapper} is build. * @return BeanMapper */ @@ -110,7 +113,11 @@ public BeanMapper beanMapper() { setUnproxy(builder); customize(builder); - return builder.build(); + BeanMapper beanMapper = builder.build(); + if (props.getDiagnosticsDetailLevel().isEnabled()) { + beanMapper = beanMapper.wrap(props.getDiagnosticsDetailLevel()).build(); + } + return beanMapper; } private void setSecuredChecks(BeanMapperBuilder builder, String packagePrefix) { diff --git a/src/main/java/io/beanmapper/autoconfigure/BeanMapperProperties.java b/src/main/java/io/beanmapper/autoconfigure/BeanMapperProperties.java index 24265b8..795f4c4 100644 --- a/src/main/java/io/beanmapper/autoconfigure/BeanMapperProperties.java +++ b/src/main/java/io/beanmapper/autoconfigure/BeanMapperProperties.java @@ -1,5 +1,7 @@ package io.beanmapper.autoconfigure; +import io.beanmapper.utils.diagnostics.DiagnosticsDetailLevel; + import org.springframework.boot.context.properties.ConfigurationProperties; /** @@ -29,6 +31,8 @@ public class BeanMapperProperties { private String strictTargetSuffix = "Result"; + private DiagnosticsDetailLevel diagnosticsLevel = DiagnosticsDetailLevel.DISABLED; + public boolean isUseHibernateUnproxy() { return useHibernateUnproxy; } @@ -76,4 +80,12 @@ public String getStrictTargetSuffix() { public void setStrictTargetSuffix(String strictTargetSuffix) { this.strictTargetSuffix = strictTargetSuffix; } + + public DiagnosticsDetailLevel getDiagnosticsDetailLevel() { + return diagnosticsLevel; + } + + public void setDiagnosticsDetailLevel(DiagnosticsDetailLevel diagnosticsLevel) { + this.diagnosticsLevel = diagnosticsLevel; + } }