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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 背包九讲——完全背包

    背包九讲——完全背包完全背包是01背包的加强版,先来看看《背包问题九讲》里是怎么描述这个问题的:题目有N种物品和一个容量为V的背包,每种物品都有无限件可用。第i种物品的费用是c[i],价值是w[i]。求解将哪些物品装入背包可使这些物品的费用总和不超过背包容量,且价值总和最大。所属专栏:戳我访问再来看看《背包问题九讲》是怎么解决这个问题的:基本思路这个问题非常类似于01背包问题,所不同

    2022年6月28日
    23
  • 1.3万亿条数据查询如何做到毫秒级响应?

    1.3万亿条数据查询如何做到毫秒级响应?

    2020年11月14日
    165
  • word2vec原理详解及实战

    word2vec原理详解及实战目录1)前言1.1语言模型1.2N-gram模型1.3词向量表示2)预备知识2.1sigmoid函数2.2逻辑回归2.3贝叶斯公式2.4Huffman编码3)神经网络概率语言模型4)基于HierarchialSodtmax模型4.1CBOW模型4.2Skip-gram模型5)基于NegativeSampling的模型5.1如…

    2022年5月16日
    42
  • Scripting.FileSystemObject详解

    Scripting.FileSystemObject详解FSO是FileSystemObject或Scripting.FileSystemObject的缩写,为IIS内置组件,用于操作磁盘、文件夹或文本文件。FSO的对象、方法和属性非常的多,这里用示例的方式列出常用的,注意:《VBScript语言参考》或《JScript语言参考》中的:《FileSystemObject用户指南》和《Scripting运行时库参考》便是微软给出的F…

    2022年7月14日
    19
  • websocket 在线工具_websocket添加请求头

    websocket 在线工具_websocket添加请求头Websocket在线模拟请求工具:支持内网和外网Websocket测试连接格式为ws://IP或域名:端口(示例ws://127.0.0.1:8080)

    2022年8月3日
    3
  • java list三种遍历方法性能比較

    java list三种遍历方法性能比較

    2021年9月1日
    55

发表回复

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

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