【发布时间】:2021-06-05 12:15:06
【问题描述】:
我偶然发现了这种使用 RestController 注解的技术。 (我不是在互联网上看到的,而是在我看到的一个例子中看到的。我在互联网上找不到它)
@RestController
@RequestMapping("api/user/point")
public interface ExampleRestController {
@PostMapping("{key}" )
@Operation(summary = "Manage...",
description = "Allow user ...")
public HttpStatus changePoints(
@PathVariable
@NotBlank
@Parameter(description = "Id user") String key,
@RequestParam("point")
@Min(0) @Parameter(description = "count something..", required = true) Long point,
@RequestParam("type")
@Parameter(description = "Type of...", required = true) TypeOperation type
);
}
这是什么技术,谁知道?
我见过这样的 Rest Api。 Spring 是否也可以像在执行 ...extend CrudRepository 时那样在 RestController 中动态创建端点方法?在这种情况下 AOP 是如何工作的?毕竟,为了配置bean,我们需要把注解放在类上面(就像在服务层是怎么做的一样),如果放在接口上面,bean的全自动配置就不行了保证
【问题讨论】:
-
以下是一个很好的起点:Spring Reference Documentation
-
请仔细阅读问题。我没有问你怎么做,我知道文档在哪里,我也没有问你怎么做,请阅读问题......
-
@skhyho 我不是反对者。我重新阅读了您的问题,但仍然认为我的第一条评论是有效的。您的问题不是针对某个主题的。可能您需要将问题分解为您面临的特定问题或您无法理解的概念。
标签: spring-boot java-11