2021年7月26日星期一

spring boot(一)hello world

一、idea创建spring boot项目

点击展开查看-IDEA创建spring boot项目

image
image
image
image
image
image
image

二、spring boot配置文件

先改一下 spring boot配置文件的后缀从application.properties 改成application.yml

1、设置spring boot端口

server: port: 10086

2、设置spring boot随机端口

我们访问某个微服务的时候,可以从注册中心获取到对应的IP及端口号
所以动态扩容的时候,可以使用随机端口启动项目

server: port: ${random.int(10000,65535)} #随机端口

3、设置服务根路径(servlet.context-path)

现在有一个hello接口代码如下:

@RestController@RequestMapping("/test")public class TestCollection { @RequestMapping("hello") public String getValue(){  return "hello world"; }}

如果配置端口是:10086

如果根路径配置如下:要访问hello接口,请求地址就是 servlet: context-path: / #设置服务的根路径

如果根路径配置如下:要访问hello接口,请求地址就是 servlet: context-path: /hello_world #设置服务的根路径

4、Spring Boot 更换 Banner

只需要在src/main/resources路径下新建一个banner.txt文件,banner.txt中填写好需要打印的字符串内容即可。
banner.txt的内容可以访问这个网站【 https://www.bootschool.net/ascii-art 】然后粘贴到banner.txt
下面是程序员常用的banner.txt内容可以直接使用:

//////////////////////////////////////////////////////////////////////       _ooOoo_        ////       o8888888o        ////       88" . "88        ////       (| ^_^ |)        ////       O\ = /O        ////      ____/`---'\____       ////     .' \\|  |// `.       ////     / \\||| : |||// \      ////     / _||||| -:- |||||- \      ////     | | \\\ - /// | |      ////     | \_| ''\---/'' | |      ////     \ .-\__ `-` ___/-. /      ////    ___`. .' /--.--\ `. . ___      ////    ."" '< `.___\_<|>_/___.' >'"".     ////   | | : `- \`.;`\ _ /`;.`/ - ` : | |     ////   \ \ `-. \_ __\ /__ _/ .-` / /     ////  ========`-.____`-.___\_____/___.-`____.-'========   ////       `=---='        ////  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  ////   佛祖保佑  永不宕机  永无BUG     //////////////////////////////////////////////////////////////////////
  0000000  0000000  000000    000  0000000000  000   000 000  000 000  00  000 000   000  000  000 000   000 00  000 000  00 000     000 000   000 000   000 00  000 000  000 00 0000    000 000    000   000 000  0000 000 0000 0000 000   000 000     000   000  000000 000  00000 00 000  000   000 000    000   000    00   000 00  000   000 000   00 000   000 000  000 00  00  00  00 000 000  0000  0000  000  000  0000000  00000000  00000000  000 000  0000000000  0000000000

三、spring boot多环境配置,按照spring.profiles.active来读取不同的配置文件

我们在yml的配置文件中,使用spring.profiles.active来读取不同的配置环境
原文转载:http://www.shaoqun.com/a/895363.html

跨境电商:https://www.ikjzd.com/

走秀网:https://www.ikjzd.com/w/2427

bsci:https://www.ikjzd.com/w/2339

r标:https://www.ikjzd.com/w/1070


一、idea创建springboot项目点击展开查看-IDEA创建springboot项目二、springboot配置文件先改一下springboot配置文件的后缀从application.properties改成application.yml1、设置springboot端口server:port:100862、设置springboot随机端口我们访问某个微服务的时候,可以从注册中心获取到对应的I
西方人,你为什么不唱K?:http://www.30bags.com/a/245400.html
西贡、会安体验越南style :http://www.30bags.com/a/414066.html
西关小姐 - :http://www.30bags.com/a/410171.html
西海岸再添新地标!青岛古镇口大学城体育馆主体封顶:http://www.30bags.com/a/225220.html
少妇口述:17岁女儿当我面和男人上床:http://lady.shaoqun.com/a/97815.html
和黑人老外性经历口述 初体验黑人40厘米巨大连接:http://lady.shaoqun.com/m/a/247108.html
强行扒开女班长大腿 班长让我脱了她的内衣:http://www.30bags.com/m/a/249773.html
少妇口述:好色男邻居趁老公出差跟我一夜情:http://www.30bags.com/m/a/249609.html
外出工作的年轻女性想用"夫妻生活"做什么?听听这些人的声音!:http://lady.shaoqun.com/a/431470.html
小说:不,我要去洗澡:http://lady.shaoqun.com/a/431471.html
女人"性冷淡"。吃什么可以帮助他们?提高性功能?:http://lady.shaoqun.com/a/431472.html
女人希望被你的睡眠所暗示。女人明白你有趣的潜台词吗:http://lady.shaoqun.com/a/431473.html

没有评论:

发表评论

注意:只有此博客的成员才能发布评论。