首页 > 解决方案 > server.servlet.context-path 无法在 AWS 环境中运行

问题描述

我刚刚在 AWS 弹性 beanstack 上托管了我的 springboot 应用程序(WAR),但发现了一个奇怪的问题

server.servlet.context-path= /app-name/api/v0

这在 localhost 上运行得非常好,但是在通过 aws 部署后它不起作用,但是所有 API 都在没有来自 AWS 的上下文路径的情况下工作:

例子 :

http://awsaddress.com/login  -> its working, but it should like 

 http://awsaddress.com/app-name/api/v0/login  -> its not working

在此处输入图像描述

标签: amazon-web-servicesspring-bootamazon-elastic-beanstalk

解决方案


我知道这个线程很老,但我面临同样的问题。在我的情况下,解决方案是在 application.properties 中添加以下行:

server.contextPath = /artifactId
server.servlet.contextPath = /artifactId

推荐阅读