Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 自动配置RestController弹簧引导_Spring_Spring Boot_Spring Restcontroller_Spring Autoconfiguration - Fatal编程技术网

Spring 自动配置RestController弹簧引导

Spring 自动配置RestController弹簧引导,spring,spring-boot,spring-restcontroller,spring-autoconfiguration,Spring,Spring Boot,Spring Restcontroller,Spring Autoconfiguration,我试图找到有关如何手动配置RestController(即在Configuation类中)的文档。这意味着不使用RestController注释。考虑到所有其他注释,如映射、路径变量等,是否有可能 控制器本质上是一个具有请求映射的组件。请参阅RequestMappingHandlerMapping @覆盖 受保护的布尔isHandler(类beanType){ return(AnnotatedElementUtils.hasAnnotation(beanType,Controller.class

我试图找到有关如何手动配置RestController(即在Configuation类中)的文档。这意味着不使用RestController注释。考虑到所有其他注释,如映射、路径变量等,是否有可能

控制器本质上是一个具有请求映射的组件。请参阅
RequestMappingHandlerMapping

@覆盖
受保护的布尔isHandler(类beanType){
return(AnnotatedElementUtils.hasAnnotation(beanType,Controller.class)||
AnnotatedElementUtils.hasAnnotation(beanType,RequestMapping.class));
}
如果您想通过配置实例化“rest控制器”,您可能可以通过以下方式实现:

@配置
公共类MyConfiguration{
@豆子
公共MyController(){
返回新的MyController();
}
}
@ResponseBody
公共类MyController{
@请求映射(“/test”)
公共字符串someEndpoint(){
返回“一些有效载荷”;
}
}
但我认为您无法在配置中配置请求映射(路径变量等);至少我还没有看到一个例子,也没有弄明白怎么做