11.3.3 “main”方法
The final part of our application is the main
method. This is just a standard method that follows the Java convention for an application entry point. Our main method delegates to Spring Boot’s SpringApplication
class by calling run
. SpringApplication
bootstraps our application, starting Spring, which, in turn, starts the auto-configured Tomcat web server. We need to pass Example.class
as an argument to the run
method to tell SpringApplication
which is the primary Spring component. The args
array is also passed through to expose any command-line arguments.
应用程序最后部分是 main
方法。 这仅仅是一个标准方法,它遵循Java应用程序进入点的规范。 我们的main
方法通过调用 run
来委托SpringBoot的SpringApplication
类。 SpringApplication
引导启动应用程序,从Spring开始,依次启动自动配置的Tomcat Web服务器。 我们需要将 Example.class
作为一个参数传递给 run
方法来告诉SpringApplication
哪个是主要的Spring组件。(main方法)args
数组同样被传递暴露于任意命令行的参数。
更多建议: