SpringBoot系列教程12SpringBoot自动配置原理探析.docx

上传人:b****5 文档编号:6015507 上传时间:2023-01-03 格式:DOCX 页数:3 大小:66.84KB
下载 相关 举报
SpringBoot系列教程12SpringBoot自动配置原理探析.docx_第1页
第1页 / 共3页
SpringBoot系列教程12SpringBoot自动配置原理探析.docx_第2页
第2页 / 共3页
SpringBoot系列教程12SpringBoot自动配置原理探析.docx_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

SpringBoot系列教程12SpringBoot自动配置原理探析.docx

《SpringBoot系列教程12SpringBoot自动配置原理探析.docx》由会员分享,可在线阅读,更多相关《SpringBoot系列教程12SpringBoot自动配置原理探析.docx(3页珍藏版)》请在冰豆网上搜索。

SpringBoot系列教程12SpringBoot自动配置原理探析.docx

SpringBoot系列教程12SpringBoot自动配置原理探析

  

 

  

SpringBoot系列教程12--SpringBoot自动配置原理探析

 

  

 

 

 

 

 

 

 

   

 

 

 

 

 

SpringBoot系列教程12--SpringBoot自动配置原理探析

作者:

一一哥

一.SpringBoot自动配置概述

1.概述

在Spring4.x之后,提供了一个按条件配置Bean的功能,并且结合“习惯优于配置”的理念,后面推出了SpringBoot这个全新的开发框架。

在SpringBoot中,自动配置可以说是精髓了。

当然这个自动配置的原理,一般也就只有在面试的时候才用得上,但是我们学习过程中也有必要了解这个自动配置,有助于加深我们对SpringBoot的了解。

2.SpringBoot的配置文件

在SpringBoot中有一个全局的配置文件:

application.properties或application.yml。

我们开发过程中,各种配置属性都可以在这个文件中进行配置,常用的一些配置属性,比如:

server.port、spring.application.name等等,当然实际开发中,我们往往只是用到很少的一部分,其实这些属性非常的多,具体可以参考下面的链接:

https:

//docs.spring.io/spring-boot/docs/2.1.0.RELEASE/reference/htmlsingle/#common-application-properties

下面截取了官方提供的部分属性:

#===================================================================

#COMMONSPRINGBOOTPROPERTIES

#

#Thissamplefileisprovidedasaguideline.DoNOTcopyitinits

#entiretytoyourownapplication.^^^

#===================================================================

#----------------------------------------

#COREPROPERTIES

#----------------------------------------

debug=false#Enabledebuglogs.

trace=false#Enabletracelogs.

#LOGGING

logging.config=#Locationoftheloggingconfigurationfile.Forinstance,`classpath:

logback.xml`forLogback.

logging.exception-conversion-word=%wEx#Conversionwordusedwhenloggingexceptions.

logging.file=#Logfilename(forinstance,`myapp.log`).Namescanbeanexactlocationorrelativetothecurrentdirectory.

logging.file.max-history=0#Maximumofarchivelogfilestokeep.Onlysupportedwiththedefaultlogbacksetup.

logging.file.max-size=10MB#Maximumlogfilesize.Onlysupportedwiththedefaultlogbacksetup.

logging.group.*=#Loggroupstoquicklychangemultipleloggersatthesametime.Forinstance,`logging.level.db=org.hibernate,org.springframework.jdbc`.

logging.level.*=#Loglevelsseveritymapping.Forinstance,`logging.level.org.springframework=DEBUG`.

logging.path=#Locationofthelogfile.Forinstance,`/var/log`.

logging.pattern.console=#Appenderpatternforoutputtotheconsole.SupportedonlywiththedefaultLogbacksetup.

logging.pattern.dateformat=yyyy-MM-ddHH:

mm:

ss.SSS#Appenderpatternforlogdateformat.SupportedonlywiththedefaultLogbacksetup.

logging.pattern.file=#Appenderpatternforoutputtoafile.SupportedonlywiththedefaultLogbacksetup.

logging.pattern.level=%5p#Appenderpatternforloglevel.SupportedonlywiththedefaultLogbacksetup.

logging.register-shutdown-hook=false#Registerashutdownhookfortheloggingsystemwhenitisinitialized.

#AOP

spring.aop.auto=true#Add@EnableAspectJAutoProxy.

spring.aop.proxy-target-class=true#Whethersubclass-based(CGLIB)proxiesaretobecreated(true),asopposedtostandardJavainterface-basedproxies(false).

#IDENTITY(ContextIdApplicationContextInitializer)

spring.application.name=#Applicationname.

#ADMIN(SpringApplicationAdminJmxAutoConfiguration)

spring.application.admin.enabled=false#Whethertoenableadminfeaturesfortheapplication.

spring.application.admin.jmx-name=org.springframework.boot:

type=Admin,name=SpringApplication#JMXnameoftheapplicationadminMBean.

#AUTO-CONFIGURATION

spring.autoconfigure.exclude=#Auto-configurationclassestoexclude.

#BANNER

spring.banner.charset=UTF-8#Bannerfileencoding.

spring.banner.location=classpath:

banner.txt#Bannertextresourcelocation.

spring.banner.image.location=classpath:

banner.gif#Bannerimagefilelocation(jpgorpngcanalsobeused).

spring.banner.image.width=76#Widthofthebannerimageinchars.

spring.banner.image.height=#Heightofthebannerimageinchars(defaultbasedonimageheight).

spring.banner.image.margin=2#Lefthandimagemargininchars.

spring.banner.image.invert=false#Whetherimagesshouldbeinvertedfordarkterminalthemes.

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 小学教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1