java - How does the EnableAutoConfiguration spring annotation work? -
i no fan of gross on abstractions, and think spring has committed major felony.
but i'm willing overlook time if can explain algorithm behind 'auto' configuration.
having @ spring's own javadocs, doesn't give much away other saying intelligently guess need , conditional beans.
does know algorithm used determine needs loaded?
in experience spring boot user basic factors spring boot decide on auto-configurations enabled are:
1) classes nowadays on classpath. illustration if rabbitmq , spring amqp classes present, rabbitautoconfiguration enabled. corresponding annotation @conditionalonclass,
2) presence or not of user defined beans. example, if spring info jpa nowadays on classpath, spring boot register localcontainerentitymanagerfactorybean bean if user has not done so. beans registered user 'override' default ones. relevant annotation @conditionalonmissingbean
as @davesyer mentions, can of course of study utilize spring boot without @enableautoconfiguration if want include relevant configuration on own. or utilize less drastic solution of exclude field of @enableautoconfiguration. if illustration want spring boot autoconfigure except activemq, utilize @enableautoconfiguration(exclude=activemqautoconfiguration.class)
in opinion, there absolutely no felony here! can utilize want spring boot. when don't want has offer, can opt out partially or completely!
also if want under covers, can add together property
logging.level.org.springframework.boot=debug
to application.properties , spring boot gladly give detailed study of auto-configured , wasn't
java spring spring-boot
No comments:
Post a Comment