2022.6.7 springboot
javase: OOP
mysql:持久化
html+css+js+jquery+框架:视图层
javaweb:独立开发MVC三层架构的网站了:原始
ssm :框架:简化了我们的开发流程,配置也开始较为复杂;
JavaWeb使用war包:tomcat运行



2、第一个springboot
第一种方式创建:(一般不用)
进入springboot官网:https://spring.io/projects/spring-boot





点击完成即可

依赖作用
1 <dependencies> 2 <!--web依赖:配置tomcat. dispatcherservLet. xmL. . .--> 3 <dependency> 4 <groupId>org.springframework.boot</groupId> 5 <artifactId>spring-boot-starter-web</artifactId> 6 </dependency> 7 8 <!--单元测试--> 9 <dependency> 10 <groupId>org.springframework.boot</groupId> 11 <artifactId>spring-boot-starter-test</artifactId> 12 <scope>test</scope> 13 </dependency> 14 </dependencies> 15 16 <build> 17 <!--打jar包插件--> 18 <plugins> 19 <plugin> 20 <groupId>org.springframework.boot</groupId> 21 <artifactId>spring-boot-maven-plugin</artifactId> 22 </plugin> 23 </plugins> 24 </build>
第二种方式创建:






导入后启动web的功能,Tomcat被集成进去了
主启动类测试
1 package com.xing.controller; 2 3 import org.springframework.stereotype.Controller; 4 import org.springframework.web.bind.annotation.RequestMapping; 5 import org.springframework.web.bind.annotation.ResponseBody; 6 7 @Controller 8 public class HelloController { 9 @RequestMapping("/hello") 10 @ResponseBody //它就不会走视图解析器,会直按返回一个字符串 返回返回值字符串hello 11 public String hello() { 12 return "hello"; 13 } 14 }

更改端口号

自定义banner
网址:https://www.bootschool.net/ascii/





浙公网安备 33010602011771号