springboot之端口设置和contextpath的配置方式

作者:吸引力的觉悟 时间:2023-10-05 14:16:20 

端口设置和contextpath的配置

端口设置

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

server.port= 9090

常用配置:

########################################################
###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 路径。

server.context-path=/spring-boot

常用配置:

########################################################
###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

Springboot中添加contextPath

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

profile配置

server.context-path=/spring-boot
server
     context-apth: /spring-boot

来源:https://blog.csdn.net/u012100371/article/details/76409388

标签:springboot,端口,contextpath
0
投稿

猜你喜欢

  • Mac OS下为Android Studio编译FFmpeg解码库的详细教程

    2023-06-30 02:37:54
  • C语言/C++中如何产生随机数

    2023-06-25 08:48:57
  • Java十分钟精通类 封装 继承

    2023-11-25 10:55:58
  • Java文件与IO流操作原理详细分析

    2023-08-12 13:13:46
  • SpringBoot使用Druid数据源的配置方法

    2023-08-19 19:52:11
  • mybatis批量新增、删除、查询和修改方式

    2023-11-23 10:13:01
  • 简单谈谈java的异常处理(Try Catch Finally)

    2021-08-01 12:40:02
  • Spring Bean自动装配入门到精通

    2023-11-03 07:29:09
  • Spring Cloud升级最新Finchley版本的所有坑

    2021-09-02 07:21:51
  • EditText限制小数点前后位数的实例

    2023-04-10 03:56:14
  • Java基础之创建虚拟机对象的过程详细总结

    2022-07-07 14:24:29
  • C#使用linq查询大数据集的方法

    2023-05-24 16:52:17
  • 微信公众号开发之设置自定义菜单实例代码【java版】

    2022-09-02 00:52:22
  • c#关于JWT跨域身份验证的实现代码

    2023-09-12 18:26:02
  • Spring整合CXF webservice restful实例详解

    2023-03-20 09:58:21
  • Android checkbox的listView具体操作方法

    2023-10-10 06:58:33
  • Java实现解析JSON大文件JsonReader工具详解

    2023-08-21 21:13:14
  • Android 中自定义Dialog样式的Activity点击空白处隐藏软键盘功能(dialog不消失)

    2022-03-10 12:15:21
  • 详谈Enumeration接口和Iterator接口的区别

    2023-05-08 02:25:23
  • 如何使用SpEL表达式实现动态分表查询

    2022-01-05 03:09:55
  • asp之家 软件编程 m.aspxhome.com