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

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

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

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • WiFi 的认证方法

    WiFi 的认证方法认证方法有两种:Opensystemauthentication与Sharedkeyauthentication。

    2022年7月11日
    40
  • vs2013安装失败解决办法_个人总结及解决方案

    vs2013安装失败解决办法_个人总结及解决方案今晚上,在机器上安装vs2008时,连续好几次都失败,开始以为是vs2005(之前装的2005)的原因,后来把2005全卸载了,还是安装失败,在错误日志里总是说版本冲突,经过网上前人经验的指点问题得到了解决,现将前辈的经验收藏分享,以造福更多的人我就开始看我indows系统的日志,没有任何红色提示,但我始终不相信我的安装文档有问题,因为同事他们也是用的这个版本(vs2008team),我更…

    2025年9月29日
    2
  • HDU 变形课[通俗易懂]

    HDU 变形课[通俗易懂]HDU 变形课

    2022年4月21日
    38
  • 权限设计-系统登录用户权限设计[通俗易懂]

    权限设计-系统登录用户权限设计[通俗易懂]需求分析—场景假设需要为公司设计一个人员管理系统,并为各级领导及全体员工分配系统登录账号。有如下几个要求:1. 权限等级不同:公司领导登录后可查看所有员工信息,部门领导登录后只可查看本部门员工的信息,员工登录后只可查看自己的信息;2.访问权限不同:如公司领导登录后,可查看员工薪水分布界面,而员工则不能看到;3.操作权限不同:如系统管理员可以在信息发布界面进行增删改查发布信息

    2022年7月13日
    18
  • Pycharm社区版创建Flask项目详解「建议收藏」

    Pycharm社区版创建Flask项目详解「建议收藏」一、在原有工程上修改1、创建工程选择newproject创建工程输入项目名,选择配置好的虚拟环境项目创建好之后是一个空的项目,里面没有任何文件,下面我们来新建工程目录2、配置工程目录在工程根目录新建app.py文件在app.py中的代码如下:fromflaskimportFlask,render_templateapp=Flask(__name__)app.config[‘SECRET_KEY’]=’1456719640@qq.com’@app.rou

    2022年8月29日
    2
  • 监控系统-Prometheus(普罗米修斯)(三)Grafana可视化图形工具

    监控系统-Prometheus(普罗米修斯)(三)Grafana可视化图形工具文章目录监控系统-Prometheus(普罗米修斯)(三)Grafana可视化图形工具Grafana入门Grafana对Prometheus的支持安装创建一个Prometheus的数据源配置dashboards参考监控系统-Prometheus(普罗米修斯)(三)Grafana可视化图形工具Github地址:https://github.com/grafana/grafana官网地址:https://grafana.com官网文档地址:http://docs.grafana.org/下载地址:ht

    2022年7月19日
    48

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

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