23. SpringApplication
SpringApplication类通过从main()方法启动,提供了一种简便的方法来引导一个Spring应用.在大多数情况下,您可以委托给静态的SpringApplication.run方法,如下例所示:
public static void main(String[] args) {SpringApplication.run(MySpringConfiguration.class, args);}
当您的应用程序启动时,您应该能看到类似以下输出的内容:
. ____ _ __ _ _/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/ ___)| |_)| | | | | || (_| | ) ) ) )' |____| .__|_| |_|_| |_\__, | / / / /=========|_|==============|___/=/_/_/_/:: Spring Boot :: v2.0.2.RELEASE2013-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 : Refreshingorg.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6e5a8246:startup date [Wed Jul 31 00:08:16 PDT 2013]; root of context hierarchy2014-03-04 13:09:54.912 INFO 41370 --- [ main] .t.TomcatServletWebServerFactory : Serverinitialized with port: 80802014-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级别的日志会信息会显示,包括一些相关的启动细节:比如启动应用程序的用户.如果你需要INFO日志级别以外的其他信息,你可以设置它,如Section 26.4 Log Levels所述.
