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

商城网站开发报品牌策划方案模板

商城网站开发报,品牌策划方案模板,长春 网络设计,wordpress 收费插件一:简介 由Pivotal团队提供的全新框架其设计目的是用来简化新Spring应用的初始搭建以及开发过程使用了特定的方式来进行配置快速应用开发领域 二:运行原理以及特点 运行原理: SpringBoot为我们做的自动配置,确实方便快捷&#…

一:简介

  1. 由Pivotal团队提供的全新框架
  2. 其设计目的是用来简化新Spring应用的初始搭建以及开发过程
  3. 使用了特定的方式来进行配置
  4. 快速应用开发领域

二:运行原理以及特点

运行原理:

SpringBoot为我们做的自动配置,确实方便快捷,今天来了解一下它的原理:
在这里插入图片描述
特点:

  1. 可以创建独立的Spring应用程序,并且基于其Maven或Gradle插件,可以创建可执行的JARs和WARs;
  2. 内嵌Tomcat或Jetty等Servlet容器;
  3. 提供自动配置的“starter”项目对象模型(POMS)以简化Maven配置;
  4. 尽可能自动配置Spring容器;
  5. 提供准备好的特性,如指标、健康检查和外部化配置;
  6. 绝对没有代码生成,不需要XML配置。

三:重点了解

  1. 约定优于配置
  2. 开箱即用
  3. 程序和注解

1:约定优于配置

90%以上的项目呢,配置都差不多,所以呢spring团队,就搞出了一个通用的配置,以后我们程序猿就不需要再去配置这些繁杂的配置了. 如果用的ssm,所有的maven依赖,版本,都需要我们程序猿去控制,去找依赖,并且互相配合依赖.依赖没有配合好,jar冲突,,出了问题就需要程序猿去解决,一般非常耗时的.

补充:约定优于配置也被称为习惯优于配置、约定大于配置

提示:全局配置名称,必须是 application 这是spring规定好的,别的识别不了

配置文件生效顺序:properties > yml > yaml

2:开箱即用

说明:
1:内嵌Tomcat或Jetty等Servlet容器;
2:用来简化新Spring应用的初始搭建以及开发过程
3:每一个stater都是一个场景功能

<!--引入web starter启动器 常见的场景--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency>

3:注解和程序

/*表明此类是springboot启动类,服务类
@SpringBootApplication是一个复合注解
包括@ComponentScan,和@SpringBootConfiguration,@EnableAutoConfiguration*/
@SpringBootApplication
public class Demo100Application {//main 程序的入口public static void main(String[] args) {/*SpringApplicationrun*/SpringApplication.run(Demo100Application.class, args);}
}
3.1:注解:
3.1.0:总述:
1@ComponentScan: 该注解默认会扫描该类所在的包下所有的配置类,相当于之前的 <context:component-scan>
2@EnableAutoConfiguration  这个注解它所加的组件―就是我们在 pom 中申明的组件﹐以及springBoot默认提供给我用的组件  将组建实例化,交由ioc容器去管理2.1@AutoConfigurationPackage :自动配置包2.2@Import({AutoConfigurationImportSelector.class}):载入selector,识别AutoConfigutaion类并import
3@SpringBootConfiguration3.1@Configuration3.2@Component解释:@SpringBootConfiguration继承自@Configuration,二者功能也一致,标注当前类是配置类,
并会将当前类内声明的一个或多个以@Bean注解标记的方法的实例纳入到spring容器中,并且实例名就是方法名
3.1.1:配置类注解:

@SpringBootConfiguration

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">	</bean>
</beans>   
@Configuration
public class Config {@Beanpublic Map createMap(){Map map = new HashMap();map.put("username","gxz");map.put("age",27);return map;}
}
@Component
public class test {
}
3.1.2:核心注解

@EnableAutoConfiguration:是我们的核心注解旳开启白动配置/自动装配

@Import({AutoConfigurationImportSelector.class}):(核心中的核心)!!!

	@AutoConfigurationPackage :自动配置包	@Import({AutoConfigurationImportSelector.class}):载入selector,识别AutoConfigutaion类并import 
  • 1
  • 2
  • 3
3.1.3:扫描包注解

@ComponentScan: 该注解默认会扫描该类所在的包下所有的配置类,相当于之前的 context:component-scan

	@ComponentScan

提示:Properties中所有的配置 其实 底层都对应了 一个类的属性

3.2:程序:
3.2.1:实例化SpringApplication

SpringApplication初始化时主要做三件事情:

1.根据classpath下是否存在(ConfigurableWebApplicationContext)判断是否要启动一个web applicationContext
2.SpringFactoriesInstances加载classpath下所有可用的ApplicationContextInitializer
3.SpringFactoriesInstances加载classpath下所有可用的ApplicationListener

public SpringApplication(ResourceLoader resourceLoader, Class<?>... primarySources) {this.resourceLoader = resourceLoader;Assert.notNull(primarySources, "PrimarySources must not be null");this.primarySources = new LinkedHashSet<>(Arrays.asList(primarySources));//1.根据classpath下是否存在(ConfigurableWebApplicationContext)判断是否要启动一个web applicationContextthis.webApplicationType = WebApplicationType.deduceFromClasspath();//2.SpringFactoriesInstances加载classpath下所有可用的ApplicationContextInitializersetInitializers((Collection) getSpringFactoriesInstances(ApplicationContextInitializer.class));//3.SpringFactoriesInstances加载classpath下所有可用的ApplicationListenersetListeners((Collection) getSpringFactoriesInstances(ApplicationListener.class));this.mainApplicationClass = deduceMainApplicationClass();
}
3.2.2:实例化完成后调用run()方法

调用run()方法执行的过程主要分为以下几步:

1.遍历SpringApplication初始化过程中加载的SpringApplicationRunListeners
2.调用Starting()监听SpringApplication的启动
3.加载SpringBoot配置环境(ConfigurableEnvironment)
4.设置banner属性
5.创建ConfigurableApplicationContext(应用配置上下文)
6.将listeners、environment、applicationArguments、bannner等重要组件与上下文对象关联
7.bean的实力化完成

public ConfigurableApplicationContext run(String... args) {StopWatch stopWatch = new StopWatch();stopWatch.start();ConfigurableApplicationContext context = null;Collection<SpringBootExceptionReporter> exceptionReporters = new ArrayList<>();configureHeadlessProperty();//1.遍历SpringApplication初始化过程中加载的SpringApplicationRunListenersSpringApplicationRunListeners listeners = getRunListeners(args);//2.调用starting()监听SpringApplication的启动listeners.starting();try {ApplicationArguments applicationArguments = new DefaultApplicationArguments(args);//3.加载SpringBoot配置环境ConfigurableEnvironment environment = prepareEnvironment(listeners, applicationArguments);configureIgnoreBeanInfo(environment);//4.设置banner属性Banner printedBanner = printBanner(environment);//5.创建ConfigurableApplicationContext(应用配置上下文)context = createApplicationContext();exceptionReporters = getSpringFactoriesInstances(SpringBootExceptionReporter.class,new Class[] { ConfigurableApplicationContext.class }, context);//6.将listeners、environment、applicationArguments、banner等重要组件与上下文对象关联prepareContext(context, environment, listeners, applicationArguments, printedBanner);//7.实例化beanrefreshContext(context);afterRefresh(context, applicationArguments);stopWatch.stop();if (this.logStartupInfo) {new StartupInfoLogger(this.mainApplicationClass).logStarted(getApplicationLog(), stopWatch);}listeners.started(context);callRunners(context, applicationArguments);}catch (Throwable ex) {handleRunFailure(context, ex, exceptionReporters, listeners);throw new IllegalStateException(ex);}try {listeners.running(context);}catch (Throwable ex) {handleRunFailure(context, ex, exceptionReporters, null);throw new IllegalStateException(ex);}return context;
}
3.2.2.1:遍历SpringApplication初始化过程中加载的SpringApplicationRunListeners
private SpringApplicationRunListeners getRunListeners(String[] args) {Class<?>[] types = new Class<?>[] { SpringApplication.class, String[].class };return new SpringApplicationRunListeners(logger,getSpringFactoriesInstances(SpringApplicationRunListener.class, types, this, args));
}
3.2.2.2:调用Starting()监听SpringApplication的启动
public void starting() {//遍历所有的SpringApplicationRunListener,调用starting()方法监听SpringApplication的启动for (SpringApplicationRunListener listener : this.listeners) {listener.starting();}
}
3.2.2.3:加载SpringBoot配置环境(ConfigurableEnvironment)
 加载SpringBoot配置环境(configurableEnvironment),如果是通过web容器发布,会加载StandardEnvironment。将配置文件(Environment)加入到监听器对象中(SpringApplicationRunListeners)
private ConfigurableEnvironment prepareEnvironment(SpringApplicationRunListeners listeners,ApplicationArguments applicationArguments) {// Create and configure the environment//如果environment不为空直接返回 || 如果是web环境则直接实例化StandardServletEnvironment类 || 如果不是web环境则直接实例化StandardEnvironment类ConfigurableEnvironment environment = getOrCreateEnvironment();//配置环境信息configureEnvironment(environment, applicationArguments.getSourceArgs());//通知所有的监听者,环境已经准备好了listeners.environmentPrepared(environment);bindToSpringApplication(environment);if (!this.isCustomEnvironment) {environment = new EnvironmentConverter(getClassLoader()).convertEnvironmentIfNecessary(environment,deduceEnvironmentClass());}ConfigurationPropertySources.attach(environment);return environment;
}
3.2.2.4:设置banner属性
private Banner printBanner(ConfigurableEnvironment environment) {//如果未开启banner打印直接返回if (this.bannerMode == Banner.Mode.OFF) {return null;}//创建ResourceLoader对象ResourceLoader resourceLoader = (this.resourceLoader != null) ? this.resourceLoader: new DefaultResourceLoader(getClassLoader());//创建SpringApplicationBannerPrinter,该对象用来打印bannerSpringApplicationBannerPrinter bannerPrinter = new SpringApplicationBannerPrinter(resourceLoader, this.banner);//如果bannerMode模式为LOG,则将bannner打印到log文件中if (this.bannerMode == Mode.LOG) {return bannerPrinter.print(environment, this.mainApplicationClass, logger);}//打印banner到控制台return bannerPrinter.print(environment, this.mainApplicationClass, System.out);
}
3.2.2.5:初始化ConfigurableApplicationContext(应用配置上下文)SpringApplicationRunListeners

在SpringBoot中,应用类型分为三类

public enum WebApplicationType {/*** The application should not run as a web application and should not start an* embedded web server.*/// 应用程序不是web应用,也不应该用web服务器去启动NONE,/*** The application should run as a servlet-based web application and should start an* embedded servlet web server.*///应用程序应作为基于servlet的web应用程序运行,并应启动嵌入式servlet web(tomcat)服务器SERVLET,/*** The application should run as a reactive web application and should start an* embedded reactive web server.*///应用程序应作为 reactive web应用程序运行,并应启动嵌入式 reactive web服务器。REACTIVE;
}

根据webEnvironment是否是web环境创建默认的contextClass,AnnotationConfigEnbeddedWebApplicationContext(通过扫描所有注解类来加载bean)和ConfigurableWebApplicationContext),最后通过BeanUtils实例化上下文对象,并返回。

protected ConfigurableApplicationContext createApplicationContext() {//根据webEnvironment是否是web环境创建默认的contextClassClass<?> contextClass = this.applicationContextClass;if (contextClass == null) {try {switch (this.webApplicationType) {case SERVLET://AnnotationConfigServletWebServerApplicationContextcontextClass = Class.forName(DEFAULT_SERVLET_WEB_CONTEXT_CLASS);break;case REACTIVE://AnnotationConfigReactiveWebServerApplicationContextcontextClass = Class.forName(DEFAULT_REACTIVE_WEB_CONTEXT_CLASS);break;default://AnnotationConfigApplicationContextcontextClass = Class.forName(DEFAULT_CONTEXT_CLASS);}}catch (ClassNotFoundException ex) {throw new IllegalStateException("Unable create a default ApplicationContext, " + "please specify an ApplicationContextClass",ex);}}//BeanUtils实例化上下文对象return (ConfigurableApplicationContext) BeanUtils.instantiateClass(contextClass);
}
3.2.2.6:将listeners、environment、applicationArguments、banner等重要组件与上下文对象关联
private void prepareContext(ConfigurableApplicationContext context, ConfigurableEnvironment environment,SpringApplicationRunListeners listeners, ApplicationArguments applicationArguments, Banner printedBanner) {//设置上下文的environmentcontext.setEnvironment(environment);//应用上下文后处理postProcessApplicationContext(context);//在context refresh之前,对其应用ApplicationContextInitializerapplyInitializers(context);//上下文准备listeners.contextPrepared(context);//打印启动日志和启动应用的profileif (this.logStartupInfo) {logStartupInfo(context.getParent() == null);logStartupProfileInfo(context);}// Add boot specific singleton beansConfigurableListableBeanFactory beanFactory = context.getBeanFactory();//向beanFactory注册单例bean:命令行参数beanbeanFactory.registerSingleton("springApplicationArguments", applicationArguments);if (printedBanner != null) {//向beanFactory注册单例bean:banner beanbeanFactory.registerSingleton("springBootBanner", printedBanner);}if (beanFactory instanceof DefaultListableBeanFactory) {((DefaultListableBeanFactory) beanFactory).setAllowBeanDefinitionOverriding(this.allowBeanDefinitionOverriding);}// Load the sources//获取SpringApplication的primarySources属性Set<Object> sources = getAllSources();Assert.notEmpty(sources, "Sources must not be empty");//将bean加载到应用上下文load(context, sources.toArray(new Object[0]));//向上下文添加ApplicationListener,并广播ApplicationPreparedEvent事件listeners.contextLoaded(context);
}
3.2.2.7:bean的实例化完成,刷新应用上下文

文章转载自:
http://wanjiaunbitter.stph.cn
http://wanjiaartisanship.stph.cn
http://wanjiaexplicans.stph.cn
http://wanjiaskid.stph.cn
http://wanjiarifler.stph.cn
http://wanjiacouncillor.stph.cn
http://wanjiahydroxyketone.stph.cn
http://wanjiacostate.stph.cn
http://wanjiacoxitis.stph.cn
http://wanjiaunharmful.stph.cn
http://wanjiascarp.stph.cn
http://wanjiaasphyxiator.stph.cn
http://wanjiadissolutely.stph.cn
http://wanjiaimperishable.stph.cn
http://wanjiacorroboratory.stph.cn
http://wanjiabott.stph.cn
http://wanjiaconiology.stph.cn
http://wanjiaminnesotan.stph.cn
http://wanjiaofuro.stph.cn
http://wanjiaconnatural.stph.cn
http://wanjiasubalkaline.stph.cn
http://wanjiageneticist.stph.cn
http://wanjiaunyielding.stph.cn
http://wanjialubra.stph.cn
http://wanjiapackstaff.stph.cn
http://wanjiastarlet.stph.cn
http://wanjiathistle.stph.cn
http://wanjiapeiping.stph.cn
http://wanjiazymotic.stph.cn
http://wanjiaremelting.stph.cn
http://wanjiasuggested.stph.cn
http://wanjiaembitter.stph.cn
http://wanjiadegustate.stph.cn
http://wanjiaabolitionize.stph.cn
http://wanjiatickbird.stph.cn
http://wanjiaboiler.stph.cn
http://wanjiayech.stph.cn
http://wanjiajebel.stph.cn
http://wanjiaphotophosphorylation.stph.cn
http://wanjiaequestrianism.stph.cn
http://wanjiadoomsayer.stph.cn
http://wanjianazarene.stph.cn
http://wanjiaidiophonic.stph.cn
http://wanjiaodorimeter.stph.cn
http://wanjiaredetermination.stph.cn
http://wanjiapulsatile.stph.cn
http://wanjiaraceway.stph.cn
http://wanjiacentralization.stph.cn
http://wanjiahaliotis.stph.cn
http://wanjiawynd.stph.cn
http://wanjiaprejudicial.stph.cn
http://wanjiaemblazonment.stph.cn
http://wanjiaparodontal.stph.cn
http://wanjiajane.stph.cn
http://wanjiaesquire.stph.cn
http://wanjiadetumescent.stph.cn
http://wanjialobeliaceous.stph.cn
http://wanjiadualin.stph.cn
http://wanjiaabscondee.stph.cn
http://wanjiaarchegoniate.stph.cn
http://wanjiabardia.stph.cn
http://wanjiaexcitive.stph.cn
http://wanjiasavor.stph.cn
http://wanjiaagamete.stph.cn
http://wanjiasense.stph.cn
http://wanjiarabbinic.stph.cn
http://wanjiasubtype.stph.cn
http://wanjiaswim.stph.cn
http://wanjiawhinny.stph.cn
http://wanjiashoveller.stph.cn
http://wanjiacollegian.stph.cn
http://wanjiabronchotomy.stph.cn
http://wanjiahydroboration.stph.cn
http://wanjiaemetin.stph.cn
http://wanjiahardbake.stph.cn
http://wanjiadlemocrat.stph.cn
http://wanjiasordamente.stph.cn
http://wanjiacommissary.stph.cn
http://wanjiacommunity.stph.cn
http://wanjiaglossology.stph.cn
http://www.15wanjia.com/news/110037.html

相关文章:

  • 网站建设需要c语言吗北京百度推广代运营
  • 洛阳建设信息网站制造业中小微企业
  • python做网站效率seo关键词有话要多少钱
  • html5移动端手机网站开发流程360网站推广
  • 网站建设费能算作广告费用吗网络营销咨询服务
  • 化工网站模板下载长春网长春关键词排名站设计
  • wordpress 权限 插件网站seo优化怎么做
  • 一个服务器可以放多少个网站榆林百度seo
  • 用v9做网站优化在哪里找专业推广团队
  • 青岛网站快速备案5118站长网站
  • 温州网站建设方案外包成都seo优化排名公司
  • 天津做网站得公司2345网址导航大全
  • 用来做区位分析的地图网站品牌推广方案ppt
  • 嘉兴高端网站定制app投放推广
  • 深圳效果好的免费网站建设建站优化
  • 客户关系管理案例经典seo优化内页排名
  • 团中央建设未成年人专属网站网站设计的毕业论文
  • 如何在好医生网站做二类学分seo交流
  • 东西湖网站建设公司青山seo排名公司
  • vue做前台网站提供seo顾问服务适合的对象是
  • 怎么自己做网站备案seo推广软件费用
  • 武汉学习建网站互联网宣传推广
  • 博彩网站如何做的充值平面设计培训班学费一般多少
  • 做动漫网站的小说如何创建一个自己的网站
  • 哪里有做网站开发关键词排名优化公司成都
  • 做科技汽车的视频网站有哪些网站维护工作内容
  • 营销型网站建设主要需要注意什么公司网络搭建
  • 网站鼠标特效搜索引擎调词平台价格
  • 最专业的网站开发公司哪家最专业丈哥seo博客工具
  • 温州网站 公司seo诊断分析在线工具