Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

The method of customizing starter for springboot

Shulou Source: shulou.com Published: 2022-06-02 09:29:44 11月15日 Update

This article introduces the relevant knowledge of "the method of springboot customizing starter". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Starter

What are the dependencies to be used in this scenario?

How to write automatic configuration

/ / some common annotations and functions of automatic configuration class configuration @ Configuration / / specify that this is a configuration class @ ConditionalOnXxx / / automatic configuration classes take effect under specified conditions @ AutoConfigureAfter / / specify the order of automatic configuration classes @ Bean / / add components @ ConfigurationProperties / / bind related configurations @ EnableConfigurationProperties / in conjunction with related XxxProperties classes to the container / / make XxxProperties effective and add to the container / / how to automatically configure classes Auto load / / configuration classes that need to be loaded automatically at startup Configure to classpath:META-INF/spring.factories # Auto Configureorg.springframework.boot.autoconfigure.EnableAutoConfiguration=\ org.springframework.boot.autoconfigure.admin.SpringApplicationAdminJmxAutoConfiguration,\ org.springframework.boot.autoconfigure.aop.AopAutoConfiguration,\

Pattern

The initiator is only used for dependency import

The automatic configuration module should be independent of the initiator

Initiator depends on automatic configuration

When in use, you only need to introduce the initiator, and the automatic configuration module is automatically imported by the initiator through dependencies.

Naming mode: custom initiator name-spring-boot-starter

This is the end of the content of "springboot's method of customizing starter". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Configuration initiator method content container time more module pattern knowledge utility achievement next function dilemma scenario actual common use situation article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Shulou Tech Info Shulou Technology Shulou Information Linux