spring_reference/II. Getting started/11.3.3. The “main” method.md

4 lines
566 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

### 11.3.3. main方法
我们的应用程序最后部分是main方法。这只是一个标准的方法它遵循Java对于一个应用程序入口点的约定。我们的main方法通过调用run将业务委托给了Spring Boot的SpringApplication类。SpringApplication将引导我们的应用启动Spring相应地启动被自动配置的Tomcat web服务器。我们需要将`Example.class`作为参数传递给run方法来告诉SpringApplication谁是主要的Spring组件。为了暴露任何的命令行参数args数组也会被传递过去。