bean for class xxx conflicts with existing, non-compatible bean definition of same name and class

记录一个小错误。

问题:

修改代码后,打包部署,启动报错:

xxx bean for class xxx conflicts with existing, non-compatible bean definition of same name and class 

译为:

XXX类与现有的、不兼容的同名和类bean定义冲突 

完整日志如下:

bean for class xxx conflicts with existing, non-compatible bean definition of same name and class

 解决:

1.仔细查看代码,发现并无同包同类名bean。

2.猜想可能是新建moudle里copy了另一moudle的类,打包时,未clean。

3.故clean install 项目子moudle,重新clean package打包项目。

完美解决。

附:maven基本命令

1.compile:项目编译命令,生成class文件及字节码文件。

2.package:项目打包命令,生成class文件及字节码文件后,在target目录下生成项目的(jar/war)文件。

3.install:命令完成了项目编译、单元测试、打包功能,同时把打好的可执行jar包(war包或其它形式的包)布署到本地maven仓库,可供其他项目使用。

4.clean:删除项目路径下的target文件。