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

CAS WAR Overlay v6.1.6自定义REST接口返回404排查求助

Hey there, let's troubleshoot that 404 issue with your custom REST controller in CAS WAR Overlay v6.1.6. Here are the most common things you might have missed:

1. Component Scanning Isn't Covering Your Package

CAS won't automatically pick up your custom controller unless you tell it to scan your package. Head over to your overlay's src/main/resources/application.properties (or application.yml) and add this line:

cas.component-scan.base-packages=com.example

Make sure the package path matches the root of where your controller lives (e.g., com.example covers com.example.rest).

2. Controller Annotations Are Missing or Incorrect

Double-check your controller class uses the right Spring annotations. CAS relies on standard Spring Web annotations to register endpoints. For example:

package com.example.rest;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/custom")
public class CustomRestController {
    @GetMapping("/hello")
    public String sayHello() {
        return "Hello from custom CAS endpoint!";
    }
}

Ensure you have @RestController and a clear @RequestMapping (or specific method annotations like @GetMapping) to define your endpoint path.

3. Your Code Isn't Being Compiled/Packaged Properly

Sometimes the overlay skips compiling custom classes if you don't run a clean build first. Try these commands in order:

./gradlew clean build
./gradlew run

This ensures your Java code is compiled and included in the CAS WAR file before starting the server.

4. CAS Security Filters Are Blocking Your Endpoint

CAS has strict security rules that might block your custom path by default. To allow access, add these lines to application.properties:

# Allow cross-origin requests if you're using Postman from a different origin
cas.security.web.cors.enabled=true
# Skip security checks for your custom endpoints (adjust if you need auth)
cas.security.web.ignore-patterns=/api/custom/**
5. You're Missing the CAS Context Path in Your Request

If CAS is running with its default context path (/cas), your full endpoint URL should include it. For example, if your controller maps to /api/custom/hello, the correct URL in Postman is:
http://localhost:8080/cas/api/custom/hello

6. Verify Your Class Is in the Build Output

Check if your compiled controller exists in the build directory: look under build/classes/java/main/com/example/rest/ for CustomRestController.class. If it's missing, there might be an issue with your project structure (make sure files are under src/main/java, not another directory) or Gradle configuration.

内容的提问来源于stack exchange,提问作者Nishant Singh

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.08 08:07:49