在controller包下新appController類別
package controller; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.support.SpringBootServletInitializer; @SpringBootApplication public class appController extends SpringBootServletInitializer { public static void main(String[] args){ SpringApplication.run(appController.class,args); } @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { return builder.sources(appController.class); } }
新indexController
新proController類別
#啟動appController類別中的main函數
瀏覽器輸入:localhost:8080 /proo
瀏覽器輸入:localhost:8080/index
@SpringBootApplication public class UdeamApplication { public static void main(String[] args) { SpringApplication.run(UdeamApplication.class, args); } }
開啟springboot配置註解,專案啟動入口,用來啟動spring容器, 啟動tomcat , 其他套件必須與此類在同級目錄或子包下
以上是如何在springboot專案中啟動main函數的詳細內容。更多資訊請關注PHP中文網其他相關文章!