What are the core annotations of SpringBoot?
SpringBoot core annotations include: @SpringBootApplication*, @Configuration, @SpringBootConfiguration, @ComponentScan, @Conditional, etc.
##1.@SpringBootApplication*
is used for the most most most of the Spring main classes The core annotation, automation configuration file, indicates that this is a SpringBoot project, used to enable various capabilities of SpringBoot. Equivalent to the combination of the three annotations @SpringBootConfigryation, @EnableAutoConfiguration, and @ComponentScan.2.@EnableAutoConfiguration
Allow SpringBoot to automatically configure annotations. After turning on this annotation, SpringBoot can configure the annotation according to the current Packages or classes on the classpath to configure Spring Beans. For example: There is the MyBatis Jar package in the current path, and the MyBatisAutoConfiguration annotation can configure each Spring Bean of Mybatis according to the relevant parameters.3.@Configuration
An annotation added by Spring 3.0 to replace the applicationContext.xml configuration file. All things that can be done in this configuration file can be registered through the class where this annotation is located.4.@SpringBootConfiguration
The variant of @Configuration annotation is only used to modify the configuration of Spring Boot. .5.@ComponentScan
An annotation added by Spring 3.1 to replace component- in the configuration file scan configuration, enable component scanning, automatically scan the @Component annotation under the package path to register the bean instance and put it in the context (container).6.@Conditional
An annotation added by Spring 4.0 to identify a Spring Bean or Configuration configuration file, the configuration will only be opened when the specified conditions are met##7.@ConditionalOnBeanCombined @Conditional annotation, when the container Configuration is enabled only if there is a specified Bean in it.
8.@ConditionalOnMissingBeanCombines the @Conditional annotation. When there is no value in the container, the Bean can be configured. .
9.@ConditionalOnClass Combining the @Conditional annotation, the configuration can only be enabled when there is a specified Class in the container.
10.@ConditionalOnMissingClassCombined @Conditional annotation, the configuration can only be enabled when no Class is specified in the container.
11.@ConditionOnWebApplicationCombined @Conditional annotation, the configuration can only be enabled when the current project type is a WEB project.
There are three types of projects:
① ANY: Any Web project
② SERVLET: Servlet Web project
③ REACTIVE: based on reactive -base Web project
12. @ConditionOnNotWebApplication combination of @Conditional annotation, the current project type is not a WEB project Only then can the configuration be enabled.
13.@ConditionalOnPropertyCombines the @Conditional annotation only when the specified property has the specified value Turn on configuration.
14.@ConditionalOnExpressionCombined @Conditional annotation, the configuration can be enabled only when the SpEl expression is true .
15.@ConditionOnJavaCombined @Conditional annotation, when the running Java JVM is in the specified version range Just open the configuration.
16.@ConditionalResourceCombined @Conditional annotation, the configuration will only be enabled when there is a specified resource in the class path .
17.@ConditionOnJndiCombines the @Conditional annotation to enable the configuration when the specified JNDI exists.
18.@ConditionalOnCloudPlatform
Combined @Conditional annotation, the configuration can only be enabled when the specified cloud platform is activated.
19.@ConditiomalOnSingleCandidate
Combined @Conditional annotation, when the specified Class has only one Bean in the container, Or there are multiple ones at the same time but the configuration is enabled only when it is preferred.
20.@ConfigurationProperties
is used to load additional configurations (such as .properties files), available in @ Configuration annotation class or @Bean annotation method. You can take a look at several ways Spring Boot reads configuration files.
21.@EnableConfigurationProperties
Generally used with the @ConfigurationProperties annotation to enable the @ConfigurationProperties annotation to configure the Bean support.
22.@AntoConfigureAfter
is used on the automatic configuration class, that is, the automatic configuration class needs to be used in another After the specified automatic configuration class is configured. For example, Mybatis's automatic configuration class needs to be installed after the data source automatic configuration class.
23.@AutoConfigureBefore
## is used on the automatic configuration class, that is, the automatic configuration class needs to be used in another Before the specified auto-configuration class is configured.24.@Import##Spring 3.0 adds annotations to import one or more @Configuration annotation modifications configuration class.
25.@IMportReSourceSpring 3.0 adds annotations to import one or more Spring configuration files. This is very useful for Spring Boot compatible old projects. Some configuration files cannot be configured through java config.
The above is the detailed content of What are the core annotations of SpringBoot?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8's JIT compilation enhances performance by compiling frequently executed code into machine code, benefiting applications with heavy computations and reducing execution times.

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

The article discusses symmetric and asymmetric encryption in PHP, comparing their suitability, performance, and security differences. Symmetric encryption is faster and suited for bulk data, while asymmetric is used for secure key exchange.

The article discusses implementing robust authentication and authorization in PHP to prevent unauthorized access, detailing best practices and recommending security-enhancing tools.

Article discusses retrieving data from databases using PHP, covering steps, security measures, optimization techniques, and common errors with solutions.Character count: 159

The article discusses strategies to prevent CSRF attacks in PHP, including using CSRF tokens, Same-Site cookies, and proper session management.

Prepared statements in PHP enhance database security and efficiency by preventing SQL injection and improving query performance through compilation and reuse.Character count: 159
