JavaWeb:SpringBootWeb快速入门
介绍
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