11.3.3 “main”方法

2018-08-14 15:05 更新

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. 應(yīng)用程序最后部分是 main方法。 這僅僅是一個(gè)標(biāo)準(zhǔn)方法,它遵循Java應(yīng)用程序進(jìn)入點(diǎn)的規(guī)范。 我們的main方法通過(guò)調(diào)用 run來(lái)委托SpringBoot的SpringApplication類。 SpringApplication引導(dǎo)啟動(dòng)應(yīng)用程序,從Spring開始,依次啟動(dòng)自動(dòng)配置的Tomcat Web服務(wù)器。 我們需要將 Example.class作為一個(gè)參數(shù)傳遞給 run 方法來(lái)告訴SpringApplication哪個(gè)是主要的Spring組件。(main方法)args數(shù)組同樣被傳遞暴露于任意命令行的參數(shù)。

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)