spring_reference/IV. Spring Boot features/22. SpringApplication.md

24 lines
1.6 KiB
Markdown
Raw Normal View History

2015-02-08 09:02:09 +00:00
### SpringApplication
SpringApplication类提供了一种从main()方法启动Spring应用的便捷方式。在很多情况下你只需委托给SpringApplication.run这个静态方法
```java
public static void main(String[] args){
SpringApplication.run(MySpringConfiguration.class, args);
}
```
当应用启动时,你应该会看到类似下面的东西(这是何方神兽??):
2015-02-08 09:03:11 +00:00
```other
2015-02-08 09:02:09 +00:00
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: v1.2.2.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] 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级别的日志信息包括一些相关的启动详情比如启动应用的用户等。