我目前正在尝试在 tomcat 服务器上使用 Eclipse 部署一个简单的网络应用程序。
当我通过 Eclipse 启动服务器时,一切看起来都很好。 localhost:8080
工作正常并显示 tomcat 主页。
但是,我的应用“tutorial-web-spring”无法访问,因为 localhost:8080/tutorial-web-spring 触发器
404。
我的应用程序已经很好地添加到我在 eclipse 服务器选项卡上的服务器 ...
顺便说一句,我更改了我的配置,因此 eclipse 使用 tomcat 安装文件夹而不是工作区元数据。
最佳答案
上下文路径
默认情况下,上下文路径是 “/”
。如果这不理想并且您需要将其更改为 tutorial-web-spring
,这是通过 application.properties(spring bot 应用程序)执行此操作的快速简单方法:
server.contextPath=/tutorial-web-spring
对于基于YAML的配置:
server:
contextPath:/tutorial-web-spring
最后,更改也可以通过编程方式完成:
@Component
public class CustomizationBean
implements EmbeddedServletContainerCustomizer {
@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
container.setContextPath("/tutorial-web-spring");
}
}
关于java - eclipse /Tomcat : tomcat home page is reachable but app is not,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48667882/