spring boot之端口设置和contextpath的配置[通俗易懂]

spring boot之端口设置和contextpath的配置[通俗易懂]端口设置Springboot默认端口是8080,如果想要进行更改的话,只需要修改applicatoin.properties文件,在配置文件中加入:1server.port=9090常用配置:1234567891011121314151617

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

端口设置

Spring boot 默认端口是8080,如果想要进行更改的话,只需要修改applicatoin.properties文件,在配置文件中加入:

1
server.port=
9090

常用配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
########################################################
###EMBEDDED SERVER CONFIGURATION (ServerProperties)
########################################################
#server.port=8080
#server.address= # bind to a specific NIC
#server.session-timeout= # session timeout in seconds
#the context path, defaults to '/'
#server.context-path=/spring-boot
#server.servlet-path= # the servlet path, defaults to '/'
#server.tomcat.access-log-pattern= # log pattern of the access log
#server.tomcat.access-log-enabled=false # is access logging enabled
#server.tomcat.protocol-header=x-forwarded-proto # ssl forward headers
#server.tomcat.remote-ip-header=x-forwarded-for
#server.tomcat.basedir=/tmp # base dir (usually not needed, defaults to tmp)
#server.tomcat.background-processor-delay=30; # in seconds
#server.tomcat.max-threads = 0 # number of threads in protocol handler
#server.tomcat.uri-encoding = UTF-8 # character encoding to use for URL decoding


ContextPath配置

Spring boot默认是/ ,这样直接通过http://ip:port/就可以访问到index页面,如果要修改为http://ip:port/path/ 访问的话,那么需要在Application.properties文件中加入server.context-path = /你的path,比如:spring-boot,那么访问地址就是http://ip:port/spring-boot 路径。

1
server.context-path=/spring-boot

常用配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
########################################################
###EMBEDDED SERVER CONFIGURATION (ServerProperties)
########################################################
#server.port=8080
#server.address= # bind to a specific NIC
#server.session-timeout= # session timeout in seconds
#the context path, defaults to '/'
#server.context-path=/spring-boot
#server.servlet-path= # the servlet path, defaults to '/'
#server.tomcat.access-log-pattern= # log pattern of the access log
#server.tomcat.access-log-enabled=false # is access logging enabled
#server.tomcat.protocol-header=x-forwarded-proto # ssl forward headers
#server.tomcat.remote-ip-header=x-forwarded-for
#server.tomcat.basedir=/tmp # base dir (usually not needed, defaults to tmp)
#server.tomcat.background-processor-delay=30; # in seconds
#server.tomcat.max-threads = 0 # number of threads in protocol handler
#server.tomcat.uri-encoding = UTF-8 # character encoding to use for URL decoding

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/192827.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • c++cstring头文件_fstream头文件

    c++cstring头文件_fstream头文件函数strcpy原型:char*strcpy(char*s1,constchar*s2);作用:将字符串2复制到字符数组1当中去说明:字符数组1的长度应不小于字符串2的长度”字符数组1″必须写成数组名形式,”字符串2″可以为字符数组名,也可以是一个字符串常量在未对字符数组1赋初值时,复制时将”字符串2″中的字符串和其后的”/0″一

  • Proteus中的电容(Capacitors)的分类[通俗易懂]

    Proteus中的电容(Capacitors)的分类[通俗易懂]AudioGradeAxial音响级轴向引线电容AxialLeadPolypropene轴向引线聚丙烯电容AxialLeadPolystyrene轴向引线聚苯乙烯电容CeramicDisc陶瓷圆片电容DecouplingDisc去耦圆片电容ElectrolyticAluminum铝质电解电容HighTempRadial径向引线高

  • load average信息详解

    load average信息详解一、什么是loadaverage?linux系统中的Load对当前CPU工作量的度量(WikiPedia:thesystemloadisameasureoftheamountofworkthatacomputersystemisdoing)。也有简单的说是进程队列的长度。LoadAverage就是一段时间(1分钟、5分钟、15分钟)内平均L

  • hmily源码解读

    hmily源码解读一阶段TRYING入口点orderService.orderPayorderService.orderPay->CglibAopProxy$DynamicAdvisedInterceptor.intercept->methodProxy.invoke->OrderServiceImpl.orderPay业务…

  • 九九乘法表java代码_java怎么实现九九乘法表

    九九乘法表java代码_java怎么实现九九乘法表java实现九九乘法表的方法:构建两层嵌套的for循环,外层for循环用于控制行,内层for循环用于控制某行上的乘法表达式,每行输出完毕后进行换行即可。思路:构建两层嵌套的for循环:外层循环用于控制行,内层循环用于控制某行上的乘法表达式。需要注意的是,每行输出完毕后,需要换行。代码实现:publicclassTest1{publicstaticvoidmain(String[]…

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号