In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
@ EnableAutoConfiguration
With this note, spring boot will guess what kind of spring application you are going to develop based on the jar dependency in classpat. For example: spring-boot-starter-web this dependency, then springboot will automatically embed tomcat and springMVC related dependencies, and at startup, launch as a web application. And look for the appropriate configuration parameters, if not, use the default value. Such as: server.port=8080
At the same time, there are some default configurations in spring boot. For example, DataSourceAutoConfiguration automatically configures dataSource. The @ EnableAutoConfiguration annotation adds these default configurations by default. At the same time, it can also be discharged.
For example: @ EnableAutoConfiguration (exclude = DataSourceAutoConfiguration.class)
@ SpringBootApplication
It is an integration of @ SpringBootConfiguration, @ EnableAutoConfiguration, @ ComponentScan. For application bootstrap.
@ Component
It is a class-level annotation. This class is automatically detected when the application is configured through annotations or xml configuration scans. Some special types of annotations derived from @ Component, such as Repository, Service, and Controller, are all Component.
@ Import
Import @ Configuration's configuration class. Equivalent to the import tag in xml.
@ Configuration
Startup configuration parameters, which are equivalent to beans in xml.
@ ConfigurationProperties
ConfigurationProperties specifies the configuration parameters in application.yml. And loaded into the corresponding class.
For example, @ ConfigurationProperties (prefix = "spring.datasource")
@ EnableConfigurationProperties
EnableConfigurationProperties specifies the class annotated by ConfigurationProperties to make it valid.
For example: @ EnableConfigurationProperties (DataSourceProperties.class)
@ Conditional
Like @ ConditionalOnClass, it's just a custom implementation.
@ ConditionalOnProperty
This class takes effect when there is a corresponding parameter in the application.yaml
For example: @ ConditionalOnProperty (prefix = "spring.datasource", name = "type").
@ ConditionalOnClass
This type takes effect when there is a class specified in the ConditionalOnClass comment in the classpath.
Such as:
Configuration@ConditionalOnClass ({DataSource.class, EmbeddedDatabaseType.class}) @ EnableConfigurationProperties (DataSourceProperties.class) @ Import ({DataSourcePoolMetadataProvidersConfiguration.class, DataSourceInitializationConfiguration.class}) public class DataSourceAutoConfiguration {}
@ ConditionalOnMissingBean
In contrast to ConditionalOnClass, when there is no annotated class in classpath. Then this configuration class takes effect.
Such as:
Configuration @ Conditional (PooledDataSourceCondition.class) @ ConditionalOnMissingBean ({DataSource.class, XADataSource.class}) @ Import ({DataSourceConfiguration.Hikari.class, DataSourceConfiguration.Tomcat.class, DataSourceConfiguration.Dbcp2.class, DataSourceConfiguration.Generic.class, DataSourceJmxConfiguration.class}) protected static class PooledDataSourceConfiguration {}
@ AutoConfigureAfter
Refers to the configuration of the current configuration class after the specified configuration configuration.
Such as:
@ Configuration@ConditionalOnClass (PlatformTransactionManager.class) @ AutoConfigureAfter ({JtaAutoConfiguration.class, HibernateJpaAutoConfiguration.class, DataSourceTransactionManagerAutoConfiguration.class, Neo4jDataAutoConfiguration.class}) @ EnableConfigurationProperties (TransactionProperties.class) public class TransactionAutoConfiguration {}
@ AutoConfigureOrder
The order of automatic configuration.
Configuration@ConditionalOnClass ({JdbcTemplate.class, PlatformTransactionManager.class}) @ AutoConfigureOrder (Ordered.LOWEST_PRECEDENCE) @ EnableConfigurationProperties (DataSourceProperties.class) public class DataSourceTransactionManagerAutoConfiguration {}
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.