There is already 'xxxController' bean method
Posted zhai1997
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了There is already 'xxxController' bean method相关的知识,希望对你有一定的参考价值。
1、在测试springmvc的程序的时候出现如下错误:
pers.zhb.controller.HelloController#hello(Model) to { /haha}: There is already ‘helloController‘ bean method pers.zhb.controller.HelloController#hello(Model) mapped.
访问指定路径后报500错误:
2、解决方案
通过查看资料,说是在配置处理器的时候不同的方法@RequestMapping注解的路径有重复
但是我的处理器只有一个的方法,并且类级别上面没有配置该注解:
@Controller
public class HelloController{
@RequestMapping("/haha")
public String hello(Model model){
model.addAttribute("msg","Good Morning!!");//封装数据
return "hello";//被视图解析器处理
}
}
通过查看配置文件发现,不同的路径映射到了同一个解析器:
<bean id="/hello" class="pers.zhb.controller.HelloController"></bean>
将配置文件中的代码删除,注解方式的配置得以正确运行
以上是关于There is already 'xxxController' bean method的主要内容,如果未能解决你的问题,请参考以下文章
There is already ‘deptController‘ bean method
解决Java中There is no getter for property XXX'XXX' in 'class XXX'的问题
There is no getter for property named xxx' in 'class java.lang.xxx'
实力踩坑:There is no getter for property named ‘XXX‘ ‘class XXX‘
解决IDEA报错Could not autowire. There is more than one bean of 'xxx' type
There is no getter for property named 'xxx' in 'class java.lang.String