【发布时间】:2021-10-05 22:44:27
【问题描述】:
我正在尝试关注来自 JournalDev 的 Spring MVC Example。
它在 Eclipse(包括 WTP 插件)中构建和运行良好:
Jul 30, 2021 2:04:52 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jul 30, 2021 2:04:52 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
Jul 30, 2021 2:04:52 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
Jul 30, 2021 2:04:54 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Jul 30, 2021 2:04:54 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
但是当我尝试从浏览器访问它时,我收到以下“HTTP 状态 404”错误:
这告诉我 Apache Tomcat 正在以某种方式运行,但配置有误(我在 http://localhost:8080/manager/html 遇到了同样的错误)
(在独立的 Tomcat 上运行这个示例 webapp 可以正常工作)
我需要做什么才能直接从 Eclipse DEBUG 角度运行这个 webapp (http://localhost:8080/spring-mvc-example/)?
【问题讨论】:
-
再次检查部署应用程序的上下文路径。默认情况下,它是您的 Eclipse 项目的名称。顺便说一句:Tomcat 7.0 已报废,您应该使用 Tomcat 8.5 或 9.0。
-
/manager/html通常不会安装在 Eclipse 上,因为 Eclipse 本身就是在做这项工作。 -
“在独立的 Tomcat 上运行这个示例 webapp 可以正常工作”,因为它已经部署在那里。您的项目是否已部署到您从 Eclipse 启动的实例中,并且是 spring-mvc-example,并带有一个欢迎页面来为该 URL 提供服务?
标签: eclipse tomcat eclipse-wtp