问题描述
- maven 项目中修改项目的包名后重新启动报错
-
原来项目运行时正常的,后来把com.fh.controller.information.picture.PictureController
和com.fh.service.information.picture.PictureService修改为com.fh.controller.information.PictureController
和com.fh.service.information.PictureService后出错启动项目报错如下错误
信息: Initializing Spring root WebApplicationContext
2015-06-06 12:04:32 -0 [localhost-startStop-1] INFO - Root WebApplicationContext: initialization started
2015-06-06 12:04:32 -184 [localhost-startStop-1] INFO - Refreshing Root WebApplicationContext: startup date [Sat Jun 06 12:04:32 CST 2015]; root of context hierarchy
2015-06-06 12:04:33 -248 [localhost-startStop-1] INFO - Loading XML bean definitions from class path resource [spring/ApplicationContext.xml]
2015-06-06 12:04:33 -483 [localhost-startStop-1] ERROR - Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [spring/ApplicationContext.xml]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'picturesService' for bean class [com.fh.service.information.PicturesService] conflicts with existing, non-compatible bean definition of same name and class [com.fh.service.information.pictures.PicturesService]
解决方案
ApplicationContext.xml这个配置中定义了一个picturesService的bean,class与原来不对应了,com.fh.service.information.pictures.PicturesService这个应该是错的
需要改成com.fh.controller.information.PictureController
解决方案二:
找了半天 终于找到原因了 原来是maven生成的class文件中还存在原来的class文件,只要吧webapp下的web-inf下面的class文件去掉就好了