springboot之端口設(shè)置和contextpath的配置方式
端口設(shè)置和contextpath的配置
端口設(shè)置
Spring boot 默認(rèn)端口是8080,如果想要進(jìn)行更改的話,只需要修改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默認(rèn)是/ ,這樣直接通過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默認(rèn)是/ ,這樣直接通過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
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
JAVA提高第八篇 動(dòng)態(tài)代理技術(shù)
這篇文章主要為大家詳細(xì)介紹了JAVA動(dòng)態(tài)代理技術(shù)的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-10-10
通過Spring AOP實(shí)現(xiàn)異常捕捉機(jī)制
在開發(fā)過程中,異常處理是一個(gè)不可忽視的重要環(huán)節(jié),合理、優(yōu)雅地處理異常不僅能提高代碼的魯棒性,還能提升系統(tǒng)的用戶體驗(yàn),本文將介紹如何通過Spring AOP實(shí)現(xiàn)一個(gè)高效的異常捕捉機(jī)制,使得異常處理變得更加優(yōu)雅和統(tǒng)一,需要的朋友可以參考下2024-08-08
Spring Cloud Eureka 服務(wù)上下線監(jiān)控的實(shí)現(xiàn)
這篇文章主要介紹了Spring Cloud Eureka 服務(wù)上下線監(jiān)控的實(shí)現(xiàn),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-09-09
Java中final關(guān)鍵字的使用與注意總結(jié)
這篇文章主要給大家介紹了關(guān)于Java中final關(guān)鍵字的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者使用Java具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2020-08-08
Mybatis分頁查詢主從表的實(shí)現(xiàn)示例
本文主要介紹了Mybatis分頁查詢主從表的實(shí)現(xiàn)示例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2024-09-09

