Open3
Auto configure of spring boot
ref
- https://learning.oreilly.com/library/view/learn-microservices-with/9781484261316/html/458480_2_En_3_Chapter.xhtml
- https://github.com/spring-projects/spring-boot/tree/main/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure
- https://zenn.dev/articles/54123320a21406/
概要
- Spring boot の auto config を徹底理解するための学習メモ
- Spring boot の auto config がブラックボックのような存在なので、分からないと色々困りごとが起きるため勉強しておく
詳細
本で勉強した内容
-
本とは
-
auto configure の対象
- https://github.com/spring-projects/spring-boot/tree/main/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure
-
spring-boot-autoconfigure (see Listing 3-3 or the online sources, at https://tpd.io/sb-starter). That Spring Boot artifact has a whole set of classes annotated with @Configuration, which are responsible for a big part of the whole Spring Boot magic.
There are classes intended to configure web servers, message brokers, error handlers, databases, and many more. Check the complete list of packages at https://tpd.io/auto-conf-packages to get a better idea of the supported tools.
-
auto configure の条件
- クラスの存在
- application profile の設定
-
Many configuration classes are conditional on the presence of other classes like the ones we analyzed, but there are other condition types, for example, parameter values in the application.properties file.
TODO
- Annotation-based configuration vs Java-based configuration
20241001追記
- AutoConfig の資料:https://qiita.com/kazuki43zoo/items/8645d9765edd11c6f1dd
