介紹
Spring
SpringBoot
入門程序
需求
步驟
修改端口
1.新建application.yml
#設置端口
server:port: 8081
入門程序-分析
為什么main方法能啟動web應用-內嵌tomcat
為什么tomcat能定位HelloController程序
請求先到DisPatcherServlet,根據路徑轉發
小結
1.主要在于Spring Boot的自動配置(@SpringBootApplication)和內嵌Web服務器。
2.請求到核心控制器,會根據請求路徑,將請求轉發給定義的Controller程序,最終有Controller程序進行邏輯處理
入門程序-打包
添加插件
<build><plugins><plugin><!--打包插件--><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins>
</build>
啟動-package
java -jar springboot.jar