Spring boot annotations

Source: Internet
Author: User

@EnableAutoConfiguration
With this annotation, spring boot will guess what kind of spring application you will be developing based on the jar dependencies in Classpat. For example: Spring-boot-starter-web this dependency, then Springboot will automatically embed the relevant dependencies of Tomcat and Springmvc, and start as a Web application at startup. The corresponding configuration parameters are found, and if not, the default values are used. such as: server.port=8080;

@Component
It is a class-level annotation. This class is automatically detected when the application is configured through annotations or when the XML configuration is scanned. According to some special types of annotations derived from @component, such as: Repository, Service, Controller, are component.

@Import
The configuration class for importing @configuration is equivalent to the import tag in XML.

@Configuration
Startup configuration parameters, equivalent to the <beans> in XML

@ConfigurationProperties
configurationproperties Specifies the configuration parameters in the APPLICATION.YML. and loaded into the corresponding class.
such as: @ConfigurationProperties (prefix = "Spring.datasource");

@EnableConfigurationPropertiesbr/>enableconfigurationproperties Specifies the class that is annotated by @configurationproperties, Make it effective.
< p="">

@ConditionalOnClassbr/> This type takes effect when there is a class specified in the @conditionalonclass annotation in classpath.
< p="">

@Configuration@ConditionalOnClass({ DataSource.class, EmbeddedDatabaseType.class })@EnableConfigurationProperties(DataSourceProperties.class)@Import({ DataSourcePoolMetadataProvidersConfiguration.class,        

@ConditionalOnMissingBeanbr/> and @conditionalonclass, in contrast, when there is no annotation specified in the Classpath class. This configuration class is in effect.
< p="">

    @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 {    }

@Conditional
As with @conditionalonclass, it's just a custom implementation.

@ConditionalOnProperty
This class takes effect when there are corresponding parameters in the Application.yaml;
Such as:@ConditionalOnProperty(prefix = "spring.datasource", name = "type")

Spring boot annotations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.