SpringBoot四大组件

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

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

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

发布了189 篇原创文章 · 获赞 34 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/qixiang_chen/article/details/98491209