搜索
首页JavaJava基础springboot的四大组件是什么?

springboot的四大组件是什么?

Nov 18, 2020 pm 05:01 PM
javaspringboot

springboot的四大组件为:1、auto-configuration组件;2、starter组件;3、springboot cli组件;4、actuator组件。

springboot的四大组件是什么?

Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程。该框架使用了特定的方式来进行配置,从而使开发人员不再需要定义样板化的配置。通过这种方式,Spring Boot致力于在蓬勃发展的快速应用开发领域(rapid application development)成为领导者。

springboot的四大组件是什么?

springboot的四大组件

  • auto-configuration:

    Auto-configuration是Spring Boot的核心特性,其约定大于配置的思想,赋予了Spring Boot开箱即用的强大能力。

  • starter:

    starter是一种非常重要的机制,能够抛弃以前繁杂的配置,将其统一集成进starter,应用者只需要在maven中引入starter依赖,SpringBoot就能自动扫描到要加载的信息并启动相应的默认配置。starter让我们摆脱了各种依赖库的处理,需要配置各种信息的困扰。SpringBoot会自动通过classpath路径下的类发现需要的Bean,并注册进IOC容器。SpringBoot提供了针对日常企业应用研发各种场景的spring-boot-starter依赖模块。所有这些依赖模块都遵循着约定成俗的默认配置,并允许我们调整这些配置,即遵循“约定大于配置”的理念。

  • springboot cli

    Spring Boot CLI(Command Line Interface)是一个命令行工具,您可以用它来快速构建Spring原型应用。通过Spring Boot CLI,我们可以通过编写Groovy脚本来快速的构建出Spring Boot应用,并通过命令行的方式将其运行起来。

  • actuator

    Actuator是Springboot提供的用来对应用系统进行自省和监控的功能模块,借助于Actuator开发者可以很方便地对应用系统某些监控指标进行查看、统计等。

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

package com.gufang.annotation;

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;

/**
 * Enable Gufang DevTool for spring boot application
 * 
 * @author chen.qixiang
 * @version 1.0.0
 * @since 1.0.0
 */
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface EnableGufangConfiguration {

}

在这里插入图片描述
在这里插入图片描述

package com.gufang.boot;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.gufang.annotation.EnableGufangConfiguration;

@Configuration
@ConditionalOnBean(annotation = EnableGufangConfiguration.class)
@EnableConfigurationProperties(GufangProperties.class)
public class GufangConfiguration {
	  @Autowired
	  private GufangProperties properties;

	  @Bean
	  public Object createBean()
	  {
		  System.out.println("Gufang="+properties);
		  return new Object();
	  }
}

在这里插入图片描述

package com.gufang.boot.context.event;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.context.ApplicationListener;

import com.gufang.annotation.EnableGufangConfiguration;
public class GufangBannerApplicationListener implements 
	ApplicationListener<ApplicationEnvironmentPreparedEvent>
{
	public static String gufangLogo =
	        "  ###################################################################################### \n" +
            "  ########        #             #                                               ######## \n" +
            "  ########   ########       #########           ### #   #   ####  #####  #####  ######## \n" +
            "  ########      #             #                #    #   #   ##    #      #   #  ######## \n" +
            "  ########    #####          ######            # #  #   #   #  #  #####  #####  ######## \n" +
            "  ########   #   #          #    #               #  #   #    # #  #      # #    ######## \n" +
            "  ########  #####          #    #             # #   # # #   ####  #####  #   #  ######## \n" +
            "  ###################################################################################### \n" +
            "                                                             \n" +
            "\n";
	public static String LINE_SEPARATOR = System.getProperty("line.separator");
	@Override
	public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
		System.out.println(buildBannerText());
	}
	private String buildBannerText() {
		StringBuilder bannerTextBuilder = new StringBuilder();
		bannerTextBuilder.append(LINE_SEPARATOR).append(gufangLogo).append(" :: Gufang ::        (v1.0.0)")
		.append(LINE_SEPARATOR);
		return bannerTextBuilder.toString();
	}
}

在这里插入图片描述
spring.factories

org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.gufang.boot.GufangConfiguration

org.springframework.context.ApplicationListener=\
com.gufang.boot.context.event.GufangBannerApplicationListener

spring.provides

provides: gufang-spring-boot-starter

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

更多编程相关知识,请访问:编程视频!!

以上是springboot的四大组件是什么?的详细内容。更多信息请关注PHP中文网其他相关文章!

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
1 个月前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
1 个月前By尊渡假赌尊渡假赌尊渡假赌
威尔R.E.P.O.有交叉游戏吗?
1 个月前By尊渡假赌尊渡假赌尊渡假赌

热工具

Dreamweaver Mac版

Dreamweaver Mac版

视觉化网页开发工具

PhpStorm Mac 版本

PhpStorm Mac 版本

最新(2018.2.1 )专业的PHP集成开发工具

螳螂BT

螳螂BT

Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

适用于 Eclipse 的 SAP NetWeaver 服务器适配器

适用于 Eclipse 的 SAP NetWeaver 服务器适配器

将Eclipse与SAP NetWeaver应用服务器集成。

WebStorm Mac版

WebStorm Mac版

好用的JavaScript开发工具