Spring-boot: Provide a diff of the condition evaluation report as part of DevTools restart

Created on 5 May 2017  路  4Comments  路  Source: spring-projects/spring-boot

When developing an application it would be useful to be able to see the effect that changes have had to what is auto-configured each time a restart is triggered. For example, you could add an ObjectMapper bean and, upon restart, the report would tell you that the conditions on JacksonAutoConfiguration.JacksonObjectMapperConfiguration.jacksonObjectMapper no longer matched.

A simple implementation could store the previous auto-configuration report in a static variable so that it's available across restarts. A more sophisticated implementation could write the report to disk. Storing to disk would allow differences to be tracked across restarts of the JVM. This would be useful for reporting the differences in auto-configuration that are triggered by adding a new dependency.

This might go some way to addressing #6647 as, upon adding @EnableWebMvc, the diff would show what no longer matched and had been switched off.

enhancement

Most helpful comment

Closed by 7674841946b61b4a42d81850c85278a6f04c24d7.

All 4 comments

See also #6743 (similar idea, but not related to devtools)

Here's an example of the condition evaluation delta when you add @EnableWebMvc that shows WebMvcAutoConfiguration becoming a negative match:

2017-11-24 14:43:40.806  INFO 63896 --- [  restartedMain] .ConditionEvaluationDeltaLoggingListener : Condition evaluation delta:


==========================
CONDITION EVALUATION DELTA
==========================


Positive matches:
-----------------

    None


Negative matches:
-----------------

   WebMvcAutoConfiguration:
      Did not match:
         - @ConditionalOnMissingBean (types: org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; SearchStrategy: all) found beans of type 'org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport' org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration (OnBeanCondition)
      Matched:
         - @ConditionalOnClass found required classes 'javax.servlet.Servlet', 'org.springframework.web.servlet.DispatcherServlet', 'org.springframework.web.servlet.config.annotation.WebMvcConfigurer'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition)
         - found ConfigurableWebEnvironment (OnWebApplicationCondition)

   WebMvcAutoConfiguration.WebMvcAutoConfigurationAdapter.FaviconConfiguration:
      Did not match:
         - Ancestor org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration did not match (ConditionEvaluationReport.AncestorsMatchedCondition)
      Matched:
         - @ConditionalOnProperty (spring.mvc.favicon.enabled) matched (OnPropertyCondition)


Exclusions:
-----------

    None


Unconditional classes:
----------------------

    None

And here's another for when you add your own ObjectMapper bean:

2017-11-24 14:45:57.723  INFO 63896 --- [  restartedMain] .ConditionEvaluationDeltaLoggingListener : Condition evaluation delta:


==========================
CONDITION EVALUATION DELTA
==========================


Positive matches:
-----------------

    None


Negative matches:
-----------------

   JacksonAutoConfiguration.JacksonObjectMapperConfiguration#jacksonObjectMapper:
      Did not match:
         - @ConditionalOnMissingBean (types: com.fasterxml.jackson.databind.ObjectMapper; SearchStrategy: all) found beans of type 'com.fasterxml.jackson.databind.ObjectMapper' objectMapper (OnBeanCondition)


Exclusions:
-----------

    None


Unconditional classes:
----------------------

    None

Closed by 7674841946b61b4a42d81850c85278a6f04c24d7.

NICE NICE NICE NICE NICE!

Was this page helpful?
0 / 5 - 0 ratings