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


相关推荐

  • enumerateObjectsUsingBlock、enumerateObjectsWithOptions、enumerateObjectsAtIndexes、makeObjectsPerfor使用

    enumerateObjectsUsingBlock、enumerateObjectsWithOptions、enumerateObjectsAtIndexes、makeObjectsPerfor使用

    2022年1月1日
    66
  • springboot 上传文件设置文件大小限制

    springboot 上传文件设置文件大小限制报错内容:org.springframework.web.multipart.MaxUploadSizeExceededException:Maximumuploadsizeexceeded;nestedexceptionisjava.lang.IllegalStateException:org.apache.tomcat.util.http.fileupload.impl.SizeLimitExceededException:therequestwasrejectedbe…

    2022年5月29日
    43
  • IDEA的下载和使用安装

    IDEA的下载和使用安装一.IDEA的下载IDEA下载地址:https://www.jetbrains.com/idea/download/#section=windowsIDEA分为两个版本:旗舰版(Ultimate)和社区版(Community)。旗舰版收费(限30天免费试用),社区版免费二.安装过程在这我们选择装旗舰版,社区版虽然免费,但是有些功能不全双击【ideaIU-2018.3.3.exe】安装文件:点击下一步(Next)选择好【文件的安装文件目录】,点击【Next】

    2022年5月31日
    162
  • MySQL 5.7调优参数详解

    MySQL 5.7调优参数详解

    2021年6月5日
    131
  • CSS3选择器介绍及用法总结[通俗易懂]

    CSS3选择器介绍及用法总结[通俗易懂]CSS3新增了很多强大的选择器它可以让我们少写一些js事件脚本我们先来看看各个版本的选择器有哪些注:ele代表element元素attr代表attribute属性,val代表value属性值:xxx都属于伪类选择器,::xxx都属于伪元素选择器有名字的选择器我尽量细分了CCS1选择器选择器类型示例说明.class类选择器.demo

    2022年7月11日
    21
  • WPF Window 窗口获得焦点和失去焦点事件

    WPF Window 窗口获得焦点和失去焦点事件Window窗口获得焦点和失去焦点事件(窗口变为背景窗口、窗口切换等都引起窗口焦点失去)Activated获得焦点事件和Deactivated失去焦点的事件:Activated:获得焦点(首次打开软件时;由别的软件切换回当前软件时;点击当前软件在任务栏的按钮时)Deactivated:失去焦点,与Activated正好相反,(Deactivated=de+activated)使用方法有两种:第一种是在XAML中声明,然后在后台书写执行代码:<W…

    2022年6月23日
    27

发表回复

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

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