springboot server.context-path=/springboot 配置不生效

springboot server.context-path=/springboot配置不生效

@RestController
public class Hellocontroller {

    @RequestMapping("/hello")
    public String hello(){
        return "this is my configuration files test project";
    }
}

原本浏览器输入localhost:8082/hello即可访问,然后在配置文件中加入

配置项目的访问路径
server.context-path= /springboot

发现还是可以继续访问,这样说明配置并没有生效。然后将配置改为

配置项目的访问路径
server.servlet.context-path= /springboot

配置生效,输入localhost:8082/hello不可访问,输入localhost:8082/springboot/hello访问成功。以上问题只是因为版本问题,在spring boot2.0之前,上下文的配置为server.context-path。而spring boot2.0之后,上下文的配置改为了server.servlet.context-path。我的springboot版本号为2.3.3。
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

啊啊啊~~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值