Part IV. Spring Boot features(Spring Boot的功能)
1 | This section dives into the details of Spring Boot. Here you can learn |
本章节将介绍SPirng Boot的细节,您可以学习到你想使用和定制的关键功能。如果您还没有准备好,您可以阅读第二部分“Getting Started”和第三部分“Using Spring Boot”章节,这样您可以具备良好的基础知识。
23. SpringApplication
1 | The SpringApplication class provides a convenient way to bootstrap |
SpringApplication类提供了一个非常便捷的方式通过main()方法去启动Spring应用。在大多数情况下,您可以通过委托给静态方法SpringApplication.run()去启动,如下:1
2
3public static void main(String[] args) {
SpringApplication.run(MySpringConfiguration.class, args);
}
1 | When your application starts, you should see something similar |
当您的应用启动后,您将看到如下的景象:1
2
3
4
5
6
7
8
9
10
11
12 . ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: v2.1.0.BUILD-SNAPSHOT
2013-07-31 00:08:16.117 INFO 56603 --- [ main] o.s.b.s.app.SampleApplication : 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] ationConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@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.TomcatServletWebServerFactory : 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)
1 | By default, INFO logging messages are shown, including some |
默认情况下,INFO级别的日志将会展示出来,包括一些相应的启动细节,诸如启动程序的用户等。如果您需要展示不仅仅是INFO级别的日志,您可以设置它,详情参照26.4章节“Log Levels”。