springboot
来源:互联网 发布:arp s绑定mac 编辑:程序博客网 时间:2024/06/10 23:09
springboot的特点
化繁为简,简化配置
备受关注,是下一代框架
微服务的入门级微框
三种启动springboot方式
第一种是在编译器中启动app类。第二种是在原项目文件中mvn spring-boot:run的mvn方式启动。第三种是先在mvn install的maven编译,找到target目录中有一个jar包文件(版本号和名称与项目相同的),使用java -jar 文件名 的方式启动
3个注解的使用:postman
a. @Value 从配置文件读取参数@Value("${tea}") private String tea;
b. @ConfigurationProperties 把yml里面一组配置参数封装成一个类 c. @Component 向SpringBoot注册一个类
![](file:///C:\Users\Administrator\AppData\Roaming\Tencent\Users\1316929035\TIM\WinTemp\RichOle\0GN0BLSPSH5)ZHWX@GEANEK.png)
![](file:///C:\Users\Administrator\AppData\Roaming\Tencent\Users\1316929035\TIM\WinTemp\RichOle\0GN0BLSPSH5)ZHWX@GEANEK.png)
@Component@ConfigurationProperties(prefix = "student")public class Student {
开发环境-生产环境
spring: profiles: active: dev@PathVariable 获取url中的数据 http://localhost:8080/{id}/hello http://localhost:8080/12/hello @RequestMapping(value = "/{id}/hello", method = RequestMethod.GET) public String sayHello(@PathVariable("id") Integer id) { return "id" + id; }@RequestParam 获取请求参数的值 http://localhost:8080/hello?id=12 @RequestMapping(value = "/hello", method = RequestMethod.GET) public String sayHello(@RequestParam(value = "id", required = false, defaultValue = "0") Integer myid) { return "id" + myid; }@GetMapping 组合注解 @GetMapping("hello") 等于 @RequestMapping(value = "/hello", method = RequestMethod.GET) @PostMapping("hello") 等于 @RequestMapping(value = "/hello", method = RequestMethod.POST)
![](file:///C:\Users\Administrator\AppData\Roaming\Tencent\Users\1316929035\TIM\WinTemp\RichOle\0GN0BLSPSH5)ZHWX@GEANEK.png)
阅读全文
0 0
- springboot
- SpringBoot
- SpringBoot
- springboot
- SpringBoot
- springboot
- SpringBoot
- springboot
- Springboot
- springboot
- SpringBoot
- SpringBoot
- Springboot
- springboot
- springboot
- Springboot
- springboot
- springBoot
- EShop .cC
- 用Navicat保存数据字典
- 每周一报 12.20
- JAVA日期操作大全
- 【scala 高级函数】快速了解scala高级函数用法
- springboot
- angular4中父组件如何调用子组件的方法
- HX711运算代码
- Strut2 OGNL知识点
- 一个简单的python爬虫爬取糗百图片
- 20171220Capstone培训班
- 在Linux里面配置jdk1.8
- eclipse中将项目打包成jar的两种方法,及其问题与解决方法
- MySQL简单主从配置