解決Mybatis @Mapper 介面名字衝突導致springboot程式啟動不起來的問題
阿新 • • 發佈:2018-12-12
有兩個同名的Mapper:
package com.clear.ims4.business.material.program.layout;
@Mapper
public interface LayoutRepository {
}
package com.clear.ims4.business.material.widget.layout;
@Mapper
public interface LayoutRepository {
}
一個屬於program的layout,一個屬於widget的layout
啟動時會報錯:
org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean name 'layoutRepository' for bean class [com.clear.ims4.business.material.widget.layout.LayoutRepository] conflicts with existing, non-compatible bean definition of same name and class [com.clear.ims4.business.material.program.layout.LayoutRepository]
解決方案:
加@Repository
@Repository("ProgramLayoutRepository")
@Repository("WidgetLayoutRepository")