Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to obtain a list of applied Spring Boot (auto) configurations

How to obtain a list of applied Spring Boot (auto or not) configurations?

like image 513
Mikhail Boyarsky Avatar asked Oct 14 '15 19:10

Mikhail Boyarsky


People also ask

Which can be used to obtain auto-configuration in spring boot?

You need to opt-in to auto-configuration by adding the @EnableAutoConfiguration or @SpringBootApplication annotations to one of your @Configuration classes. You should only ever add one @EnableAutoConfiguration annotation. We generally recommend that you add it to your primary @Configuration class.

What are the ways in which spring boot can read configurations?

Spring Boot lets you externalize your configuration so that you can work with the same application code in different environments. You can use properties files, YAML files, environment variables, and command-line arguments to externalize configuration.

What is the difference between @configuration and AutoConfiguration?

AutoConfiguration classes are run last (meaning after all regular non-autoconfiguration classes) while the order in which Configuration classes are run is indeterminate (except if we use ordering annotations like @Ordered ) To declare a class as an AutoConfiguration they need to be specified as such in the spring.


1 Answers

After you get your artifact built, you can get an auto-configuration report if you start it including the --debug command parameter:

java -jar artifact.jar --debug

or directly adding it as a parameter for SpringApplication.run()

SpringApplication.run(WebApp.class, "--debug");

or inside the IDE, by adding --debug as an argument in your launch configuration.

The report will look like this:

=========================
AUTO-CONFIGURATION REPORT
=========================


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

   AopAutoConfiguration
      - @ConditionalOnClass classes found: org.springframework.context.annotation.EnableAspectJAutoProxy,org.aspectj.lang.annotation.Aspect,org.aspectj.lang.reflect.Advice (OnClassCondition)
      - matched (OnPropertyCondition)

   AopAutoConfiguration.JdkDynamicAutoProxyConfiguration
      - matched (OnPropertyCondition)

   AuditAutoConfiguration#authenticationAuditListener
      - @ConditionalOnClass classes found: org.springframework.security.authentication.event.AbstractAuthenticationEvent (OnClassCondition)

   AuditAutoConfiguration#authorizationAuditListener
      - @ConditionalOnClass classes found: org.springframework.security.access.event.AbstractAuthorizationEvent (OnClassCondition)

   AuditAutoConfiguration.AuditEventRepositoryConfiguration
      - @ConditionalOnMissingBean (types: org.springframework.boot.actuate.audit.AuditEventRepository; SearchStrategy: all) found no beans (OnBeanCondition)

[...]

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

   ActiveMQAutoConfiguration
      - required @ConditionalOnClass classes not found: javax.jms.ConnectionFactory,org.apache.activemq.ActiveMQConnectionFactory (OnClassCondition)

   AopAutoConfiguration.CglibAutoProxyConfiguration
      - @ConditionalOnProperty missing required properties spring.aop.proxy-target-class  (OnPropertyCondition)

   AtomikosJtaConfiguration
      - required @ConditionalOnClass classes not found: com.atomikos.icatch.jta.UserTransactionManager (OnClassCondition)
like image 149
guido Avatar answered Sep 25 '22 15:09

guido