2016-05-21 23 views
0

我正在開發一個簡單的maven + spring應用程序,並且出現以下錯誤。它說我的兩個班級有衝突。所以我刪除了第二堂課,但我仍然得到相同的錯誤。我嘗試重新啓動服務器,但它仍然說我的課程存在。有人可以幫忙嗎?即使在刪除類後也發生ConflictingBeanDefinitionException

Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.nibm.config.RootConfig]; nested exception is org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'employeeController' for bean class [com.nibm.hibernate.controller.EmployeeController] conflicts with existing, non-compatible bean definition of same name and class [com.nibm.controller.EmployeeController] 
+0

您必須刪除第二個類,但它仍將位於服務器的部署目錄中。請嘗試手動刪除服務器的部署目錄。您正在使用哪個服務器。 – shankarsh15

+0

我正在使用glassfish。在web.xml中找不到任何類。 –

回答

0

因爲你有相同類的春豆你得到的異常。

此異常 org.springframework.context.annotation.ClassPathBeanDefinitionScanner#相適應

,扔看着它看起來,如果你在你的RootConfig創建類型EmployeeController的bean作爲,另外通過ComponentScan該實現。

要解決該問題,請從RootConfig中移除Bean或更改您的ComponentScan,以免它找到此Bean。

您可以在EmployeeController的構造函數中設置斷點。從堆棧中,您可以獲得有關如何以及爲什麼創建bean的更多信息。

相關問題