java中的四大组件_springboot的四大组件是什么?

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

215f38e1be53cefee83333c70d2e8ef5.png

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

f5f3336bf3e93bec5d265cf00ccdca2e.png

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开发者可以很方便地对应用系统某些监控指标进行查看、统计等。

60af785f59b1a4120d2966ebfbd11f38.png

0f8517b55ccdd190b9c133e626e5a0b6.png

218b6d2b0d6530dbf976c5ba4d3f5cf7.png

471e0a5dab933cb96bc76806b2a1dbec.png

33aa2cf6a2dfda9332d90f0a9ad8b65c.png

fbdda7c1085e225467dda49dcf7f5f45.png

f53342a5bf0e835283bef430177862da.png

d3a222ff9d6842a67e3343f52bf6abfb.png

a4a49ee0e70f1797bca8c5656fe7601d.pngpackage 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 {

}

9ce3b8f198ae1943e7b08ea5f1843d99.png

4431e63bb4165b8c97d5756844ddb38a.pngpackage 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();

}

}

25e3d436a9603809f5aad00bf18d3601.pngpackage 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

{

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();

}

}

34b0f95d0eb08a4bb868d63225a44d0e.png

spring.factoriesorg.springframework.boot.autoconfigure.EnableAutoConfiguration=\

com.gufang.boot.GufangConfiguration

org.springframework.context.ApplicationListener=\

com.gufang.boot.context.event.GufangBannerApplicationListener

spring.providesprovides: gufang-spring-boot-starter

ec74ad4eec8feb8e67ad9a6d13babbb1.png

b9d194503339b24eec63276639bf9951.png

1f5b2d50dc799c56202b4cbd82f72192.png

ef2e56d74a20eb7224239ef26259c309.png

9e65c6461c21eb57695baefd4169b33e.png

d7148349412d698ea10672f4e14ec846.png

7250518094c094006b82aec66385c344.png

06bcb942ab9a4fa0214b64ef9a8a5d2b.png

a29c671a793d4fd85943baa84a72ef6b.png

cf139f87d9c6b5977324850187088b2c.png

4adb7850c8aa0ecb2c4f188d541ac686.png

65908152abf265ccbfb7af2bc4d4aa55.png

eccdc6d9e78436123763f21135d28674.png

88deb52d3711806a35748837fe9f0f68.png

fcc8219da35667fdb20f3f9855a40d1e.png

e297e3d073f58ba58d385702b63ce801.png

11db4e20e41fc1b4a7d721bfe4377208.png

fab3505e958919494daad5ef241aea35.png

de5d71ead0364f0a986bc5fef3ad5c70.png

ded0a1284978ac46d9dd82ea8a3b7464.png

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

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值