tomcat - 当应用程序部署在 tomcat 中时加载 server.context 路径的 Spring 引导问题

标签 tomcat spring-boot

我正面临 spring boot 的问题。当我将 spring boot 作为独立应用程序运行时,它正在考虑 server.context-path。 但是当我在 tomcat 容器(不是 spring boot 中的默认设置)中部署相同的应用程序时,它不考虑 server.context-path 并在根上下文中加载应用程序。

http://localhost:8080/book-service/ (部署在tomcat上)

{
   "_links" : {
"users" : {
  "href" : "http://localhost:8080/book-service/users{?page,size,sort}",
  "templated" : true
},
"profile" : {
  "href" : "http://localhost:8080/book-service/profile"
}
 }
}

http://localhost:9001/v1.0/ (作为 spring boot 应用程序运行,它正在考虑上下文路径(v1.0)

{
"_links" : {
"users" : {
  "href" : "http://localhost:9001/v1.0/users{?page,size,sort}",
  "templated" : true
},
"profile" : {
  "href" : "http://localhost:9001/v1.0/profile"
}
}
}

最佳答案

使用下面的属性

                      spring.data.rest.basePath=/v1.0

关于tomcat - 当应用程序部署在 tomcat 中时加载 server.context 路径的 Spring 引导问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46292042/

相关文章:

java - 为什么我们需要两次在 tomcat logging.properties 中写入处理程序?

apache - 如何在本地主机上正确启用 SSL

java - 覆盖 Apereo CAS 5 时没有 web.xml

java - Spring boot从类路径加载H2 db文件

java - IBM Websphere 8.5.5在Servlet 3.0中使用数据源4.0版本

java - 如何转换复杂对象列表并将其表示在值 yaml 图表中

java - 如何使用 Spring JNDITemplate 读取 Tomcat 环境条目

tomcat - 以低权限用户身份运行tomcat应用程序?

spring-boot - Spring Cloud 领事 : Unable to override defaults in ConsulProperties

java - Spring 启动: @PreAuthorize gives 403 forbidden AccessDeniedException