当前位置: 首页 > news >正文

湖南关键词优化快速seo属于什么

湖南关键词优化快速,seo属于什么,天津网站怎么做seo,北京建设监督网站Spring Boot是一个功能强大、灵活且易于使用的框架,它极大地简化了Spring应用程序的开发和部署流程,使得开发人员能够更专注于业务逻辑的实现。在我们的Spring Boot 3系列之一(初始化项目)文章中,我们使用了Spring官方…

Spring Boot是一个功能强大、灵活且易于使用的框架,它极大地简化了Spring应用程序的开发和部署流程,使得开发人员能够更专注于业务逻辑的实现。在我们的Spring Boot 3系列之一(初始化项目)文章中,我们使用了Spring官方网站生成的Spring Boot项目作为示例。在该项目中,我们可以找到一个名为XjdocApplication的启动类,它是Spring Boot应用程序的入口点。本文将详细解释这个启动类的作用和功能。

springbootApplication.jpg

Spring Boot启动类

在Spring Boot中,启动类是整个应用程序的入口点。一般是放在项目的根路径下的(推荐放在项目的根路径下)。它是一个标注了 @SpringBootApplication 注解的 Java 类,必须包含一个标准的 main 方法,在main方法中添加SpringApplication.run()方法,用于启动 Spring Boot 应用程序。

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication
public class XjdocApplication {public static void main(String[] args) {SpringApplication.run(XjdocApplication.class, args);}
}

启动类上边的@SpringBootApplication是 注解应用启动的入口类,它自动开启了许多有用的特性,如自动配置、组件扫描、筹划配置类等,从而减少了开发人员的配置工作量。@SpringBootApplication是Spring Boot启动类上的核心注解,是一个组合注解,源码如下:

@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan(excludeFilters = {@Filter(type = FilterType.CUSTOM,classes = {TypeExcludeFilter.class}
), @Filter(type = FilterType.CUSTOM,classes = {AutoConfigurationExcludeFilter.class}
)}
)
public @interface SpringBootApplication {...
}

他主要组合了以下3个注解:

  • @SpringBootConfiguration:表明被注解的类是一个配置类,用于定义应用程序的配置信息。
  • @EnableAutoConfiguration:开启自动配置功能。
  • @ComponentScan:启用组件扫描,使得Spring能够自动发现和装配一些组件

关系图如下:

springbootApplication.png

注解@SpringBootConfiguration

@SpringBootConfiguration 是Spring Boot提供的特定注解之一,它用于指示一个类是Spring Boot应用程序的配置类。该注解组合了 @Configuration 注解,它表示被标注的类可以作为配置类用于配置应用程序的上下文。与 @Configuration 注解类似,它通常与其他注解一起使用,用于定义和管理应用程序的配置信息。源码如下:

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.AliasFor;
import org.springframework.stereotype.Indexed;@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Configuration
@Indexed
public @interface SpringBootConfiguration {@AliasFor(annotation = Configuration.class)boolean proxyBeanMethods() default true;
}

@Configuration 注解源码如下:

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
import org.springframework.stereotype.Component;@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
public @interface Configuration {@AliasFor(annotation = Component.class)String value() default "";boolean proxyBeanMethods() default true;boolean enforceUniqueMethods() default true;
}

注解@EnableAutoConfiguration

@EnableAutoConfiguration 是Spring Boot框架中的一个重要注解,它允许应用程序根据类路径中的依赖自动配置其组件。通过这个注解,Spring Boot可以根据应用程序的依赖关系自动配置各种组件。源码如下:

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.context.annotation.Import;@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@AutoConfigurationPackage
@Import({AutoConfigurationImportSelector.class})
public @interface EnableAutoConfiguration {String ENABLED_OVERRIDE_PROPERTY = "spring.boot.enableautoconfiguration";Class<?>[] exclude() default {};String[] excludeName() default {};
}

注解@ComponentScan

@ComponentScan 是Spring框架中的一个注解,用于指定Spring在哪些包中寻找组件。它会自动扫描并注册指定包中的所有带有 @Component 及其派生注解的类作为Spring的Bean。这样可以方便地将自定义的类纳入Spring的上下文中,使得它们可以被自动装配和使用。下面是对 @ComponentScan 注解的详细解释:

  • 指定扫描包: @ComponentScan 注解允许开发人员指定要扫描的包路径。在指定的包及其子包(默认当前目录及所有子目录)中,所有带有 @Component 及其派生注解的类都将被自动注册为Spring的Bean,这也是推荐把它放在项目根路径下的原因。

  • 自动注册组件: 通过 @ComponentScan 注解,开发人员可以方便地将自定义的类纳入Spring的上下文中,使得它们可以被自动装配和使用。这样可以提高开发效率,同时减少手动配置的工作量。

  • 定制扫描规则: @ComponentScan 注解还支持一些参数配置,允许开发人员定制扫描规则,如指定特定的注解、过滤规则等,以满足特定的需求。

源码如下:

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.core.annotation.AliasFor;@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Documented
@Repeatable(ComponentScans.class)
public @interface ComponentScan {...
}

总结

Spring Boot启动类是构建Spring Boot应用程序的关键组成部分。它允许开发人员配置和管理应用程序的行为,同时简化了应用程序的配置和部署过程。通过深入了解Spring Boot启动类的功能和用法,开发人员可以更好地构建和管理复杂的Spring Boot应用程序。希望本文能够帮助您更好地理解和使用Spring Boot启动类。

http://www.hkea.cn/news/377266/

相关文章:

  • 做外贸是用什么网站做新型网络营销方式
  • 心理咨询网站开发百度手机seo软件
  • 17网站一起做网批seo营销优化
  • 做赚钱网站程序员培训班要多少钱
  • 已经收录大规模修改收录页面对网站有影响吗什么软件可以推广自己的产品
  • 丁香园做科室网站厦门网络推广
  • 免费的企业网站制作提高网站权重的方法
  • 兰州网站制作怎么样网页在线生成
  • 自建网站网址雅虎搜索引擎首页
  • 注册科技有限公司可以做网站吗百度搜索排名机制
  • 武汉做网站好网站制作多少钱一个
  • 安阳网站建设怎么从网上找客户
  • 文章博客媒体网站模板怎样在百度上打广告
  • 做网站是不是要模板直接打开百度
  • 哪个网站做app推广服务商
  • 中国哪里在大建设网站优化培训学校
  • 自己做的网站点首页出错腾讯广告代理商加盟
  • 如何做免费的网站推广东莞百度seo
  • 宜昌网站制作公司百度竞价官网
  • 建站公司网站模板论坛怎么建网站
  • 上海做b2b网站公司深圳公司网络推广该怎么做
  • 自己做的网站怎么在百度可以查到网络小说网站三巨头
  • 怎么做网站客服弹窗站长之家seo工具包
  • 自己建一个电商网站吗网络营销的定义
  • 专门做金融的招聘网站四川seo选哪家
  • wordpress nginx伪静态配置拼多多seo怎么优化
  • 深圳网站开发电话惠州网络营销
  • 中宁网站建设公司商城全网推广运营公司
  • 网站文章列表如何排版郑州seo技术培训班
  • 小型b2c网站百度开户渠道商哪里找