springboot的contextpath设置

一般情况下,我们构建的springboot工程不会使用contextpath的,使用contextpath的这种模式已经很老很老,而且有很多弊端。

但是,假如确实有需要用contextpath的话,springboot也提供了这种模式。

server.context-path=yourcontextpathname #这个是springboot 2.0 以前的写法

server.servlet.context-path=yourcontextpathname #这个是springboot 2.0 以后的写法

假如使用了 dubbox,并暴露了 rest,那么在启动的时候,别忘记了也要修改 dubbox 定义的 contextpath 路径,否则会误以为上述的修改没有作用导致启动报错,我就是犯过这样的错误,导致花了不少时间查找资料。

发表评论

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