You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Boot新手启动Pivotal Server后遇Chrome HTTP 404错误求助

解决Spring Boot项目部署到Pivotal Server 3.2后出现HTTP 404的问题

Hey there, let's work through this 404 issue step by step—since you're new to Spring Boot and Pivotal Server, we'll start with the basics to make sure nothing's missed.

1. 先确认技术栈兼容性

First off, Pivotal tc Server 3.2 is built on top of Tomcat 7. If your Spring Boot project uses version 2.x or higher, that's a core problem because Spring Boot 2.x requires Tomcat 8.5 or newer.

  • Check your pom.xml (or build.gradle) for the Spring Boot version. If it's 2.x+, you have two valid options:
    • Downgrade Spring Boot to 1.x (fully compatible with Tomcat 7)
    • Upgrade your Pivotal Server to a newer release (like 4.x+) that supports Tomcat 8.5+

2. 确保项目打包为WAR格式

Spring Boot defaults to JAR packaging, but Pivotal Server (a servlet container) needs WAR files to deploy properly:

  • Open your pom.xml and set <packaging>war</packaging> (replace the default jar)
  • Add a ServletInitializer class alongside your main Spring Boot application class to enable deployment to a servlet container:
    public class ServletInitializer extends SpringBootServletInitializer {
        @Override
        protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
            return application.sources(YourApplicationClassName.class);
        }
    }
    
    Make sure this class is in the same package as your main app class so it gets scanned correctly.

3. 正确部署项目到Pivotal Server

Let's walk through the deployment steps in STS to avoid misconfiguration:

  • Right-click your project → Run As → Run on Server
  • Select your configured Pivotal Server 3.2 from the list, then click Next
  • Move your project from the "Available" list to "Configured" (this tells the server to deploy it)
  • Click Finish and wait for the server to start fully—keep an eye on the Console tab for any startup errors.

4. 验证你的访问路径

A lot of 404s happen just because the URL is wrong:

  • When deploying a WAR, the default context path is your WAR file's name. So if your WAR is my-spring-app.war, the base URL is http://localhost:8080/my-spring-app/
  • Check your controller's @RequestMapping annotations. For example, if you have:
    @RestController
    public class HelloController {
        @RequestMapping("/greet")
        public String greet() {
            return "Hello from Spring Boot!";
        }
    }
    
    You need to visit http://localhost:8080/my-spring-app/greet to see the response.
  • Double-check that your main application class has the @SpringBootApplication annotation—this enables component scanning, so your controllers get picked up.

5. 从服务器日志里找线索

If everything above checks out, look at the server logs to find hidden issues:

  • In STS, check the Console tab while the server starts. Look for errors like:
    • ClassNotFoundException: Means a dependency is missing from your WAR
    • BeanCreationException: Indicates a Spring configuration error
    • Port conflict messages: If 8080 is in use, edit your server settings in STS (double-click the server in the Servers view) to use a different port like 8081.
  • You can also find log files in your Pivotal Server installation directory under logs/ (look at catalina.log or localhost.log for detailed errors).

6. 用极简项目做测试

If you're still stuck, create a super simple Spring Boot project to isolate the issue:

  • Use STS's Spring Starter Project wizard, select only the "Web" dependency
  • Package it as a WAR, deploy it to Pivotal Server, and test the basic endpoint. If this works, the problem is likely in your original project's configuration (like custom filters, database setups, etc.).

内容的提问来源于stack exchange,提问作者Soumadip Chakraborty

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 12:06:25