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

Spring Boot 3.2.1中RestController端点失效问题求助

问题概述
  • 基于Java 17的Spring Boot 3.2.1应用,引入包含@Entity注解的类库,使用Spring Boot默认的Hibernate连接数据库,数据库连接正常,但@RestController中定义的端点无法正常工作。
  • 此前通过类库初始化数据库(传入字符串值)时使用的是EclipseLink而非Hibernate;现在新增@EntityScan来扫描类库中的实体,之前依赖的是persistence.xml配置。
  • Spring Boot内部可正常连接数据库,但@RequestMapping映射失效,已将EntityManagerFactory传入类库使用。
  • 未使用Repository,不确定是否会影响功能。

控制器代码

@RestController
@RequestMapping("${com.example.apiPrefix}/data")
public class MyController extends GodController {

  @Autowired
  private KafkaTemplate<Integer, MyWrapper> kafkaTemplate;

  
  @GetMapping(value = "/id", produces = {"application/json"})
  @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Description...")
  public ResponseEntity<MyWrapper> getId() throws DatatypeConfigurationException {

    ResponseEntity<MyWrapper> res = null;

    .
    .
    .
    .
    return res;
  }

}

父类GodController代码

@RequestMapping("${com.example.apiPrefix}")
@OpenAPIDefinition(
        info = @Info(
                title = "Hello World",
                version = "1.0",
                description = "Description"
        )
)
public class GodController {

  @Autowired
  Library libr;

  
  public SctrzController() {
  }
  
}

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.28 21:57:14