23.springApplication (翻译)

在 SpringApplication 中提供了 main()方法 用于 spring 容器运行

在很多情况(situations)下 ,你可以 委托(delegate)给经静态的

SpringApplication.run方法

public static void main(String[] args) { 
    SpringApplication.run(MySpringConfiguration.class, args);
}

当你的运行时,你会看到相似的事情 :

.   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::   v1.4.0.M2
2013-07-31 00:08:16.117  INFO 56603 --- [
 Starting SampleApplication v0.1.0 on mycomputer with PID 56603 (/apps/myapp.jar started by pwebb)
2013-07-31 00:08:16.166  INFO 56603 --- [           main] ationConfigEmbeddedWebApplicationContext :
 Refreshing
 org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6e5a8246:
 startup date [Wed Jul 31 00:08:16 PDT 2013]; root of context hierarchy
2014-03-04 13:09:54.912  INFO 41370 --- [           main] .t.TomcatEmbeddedServletContainerFactory :
 Server initialized with port: 8080
2014-03-04 13:09:56.501  INFO 41370 --- [           main] o.s.b.s.app.SampleApplication            :
 Started SampleApplication in 2.992 seconds (JVM running for 3.658)一

一些默认INFO 日志消息打印出来 ,包括一些容器相关(relevant)的启动信息

23.1 自定义Banner(Customzing the Banner)

Banner打印的信息,你可能通过修改banner.txt 在你的classpath下,

或者设置banner.location 来配置 一个文件,如果文件不是平常的编码,

你可以通过设置banner.charset(默认UTF-8)。在添加 text文件的时候,你也可以添加一个

banner.gif,banner.jpg 或者banner.png 在你的 classpth下 ,或者设置banner.image.location

property,图片会转换(converted) ASCII 样式(art) 展现(representation)出来,并且打印出来

文字的banner. 内置的 banner.txt 文件,你可以使用下面任意的占位符

表格 23.1 Banner 参数

参数说明
${application.version}
 
${application.formatted-version} 
${spring-boot.version} 
${spring-boot.formatted-version} 
${Ansi.NAME} (or ${AnsiColor.NAME}, ${AnsiBackground.NAME}, ${AnsiStyle.NAME}) 
${application.title} 

提示:

SpringApplication.setBanner(...)方法,可以让你生成  你自己程序(programmatically)

定义的Banner, 使用org.springframework.boot.Banner接口 并且实现你自己定义的

printBanner()方法

你也可以使用spring.main.banner-mode 属性 查明(datermine)  当banner是通过

System.out(console)打印出来的,使用配置的日志或者 不是

在打印的banner 是已经注册到了 单例(singleton)的bean中 它的名字是springBootBanner.

Note

YAML maps off 是false 你可以使用这个标签,在你想关闭banner 在的容器中

spring: 
 main: 
  banner-mode: "off"

 

配置结果 :

转载于:https://my.oschina.net/lavedream/blog/3064534

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值