今天在更新别人的代码后启动项目报错了,如下:
public void com.demo.XXXControl.addUserFromRegister(java.util.Map<java.lang.String, java.lang.String>,javax.servlet.http.HttpServletResponse) throws java.io.IOException
to {[/register],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'xxxCtrl' bean
<pre name="code" class="java">分析原因:创建bean的时候出错,重复创建了<span style="font-family: Arial, Helvetica, sans-serif;">xxxCtrl bean。我查看了代码发现对应的controller中只有一个@</span><span style="font-family:Arial, Helvetica, sans-serif;">controller,没有重复的注解。后面发现是该controller与另外的controller的</span><span style="font-family: Arial, Helvetica, sans-serif;">@RequestMapping</span><span style="font-family: Arial, Helvetica, sans-serif;">(</span><span style="font-family: Arial, Helvetica, sans-serif;">"/register"</span><span style="font-family: Arial, Helvetica, sans-serif;">)相同的,url相同导致创建的时候失败。</span>
<pre>解决的方法:1、<span style="font-family: Arial, Helvetica, sans-serif;">@RequestMapping</span><span style="font-family: Arial, Helvetica, sans-serif;">(</span><span style="font-family: Arial, Helvetica, sans-serif;">"/register"</span><span style="font-family: Arial, Helvetica, sans-serif;">)重命名;2、在controller类中加上URL前缀。</span>