RestController有相同类名引起的异常(其它类型的bean也会有这种问题)
@RestController
@RequestMapping("/testnum4")
public class TestnumRest {
RestController有相同类名引起的异常(其它类型的bean也会有这种问题):
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [springmvc-servlet.xml];
nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'testnumRest' for bean class [com.test.af4.rest.TestnumRest] conflicts with existing, non-compatible bean definition of same name and class [com.test.af3.rest.TestnumRest]
因为spring默认是以类名将第一个字母改成小写,当作bean的名称,如上面的,是testnumRest.
这样就冲突了。spring为什么为用带包名的名称作为默认bean名呢???
改成以下的,可以解决。
@RestController("testnum4")
@RequestMapping("/testnum4")
public class TestnumRest {