2 paker1989 paker1989 于 2017.01.05 15:29 提问

dubbo spring boot spring-data-jpa报错 10C

当有多个service实现类注入同一个Repository时,就报下面的错:

 Caused by: java.lang.IllegalArgumentException: Repository interface must not be null on initialization!
    at org.springframework.util.Assert.notNull(Assert.java:115) ~[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:263) ~[spring-data-commons-1.12.2.RELEASE.jar:na]
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:213) ~[spring-data-commons-1.12.2.RELEASE.jar:na]
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:50) ~[spring-data-commons-1.12.2.RELEASE.jar:na]
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168) ~[spring-beans-4.3.2.RELEASE.jar:4.3.2.RELEASE]
    ... 255 common frames omitted

1、可以正常启动的情况

 @Service(version = "1.0.0")
public class EmployeeAccountServiceImpl implements EmployeeAccountService {
    @Autowired
    EmployeeRepository employeeRepository;

2、不能正常启动的情况

 @Service(value = "employeeAccountService")
//@Service(version = "1.0.0")
public class EmployeeAccountServiceImpl implements EmployeeAccountService {
    @Autowired
    EmployeeRepository employeeRepository;
 <dubbo:service  interface="com.xxx.service.employee.EmployeeAccountService" ref="employeeAccountService" version="1.0.0" validation="true"/>

2个回答

sun1021873926
sun1021873926   Ds   Rxr 2017.01.05 15:39

把你关于jpa接口相关的代码贴出来呀

sun1021873926
sun1021873926 需要注册到dubbo中心的服务,使用@Service(version = "1.0.0")这种注解,使dubbo可以对外提供服务,内部使用可以考虑使用@Component去替换@Service
12 个月之前 回复
u012253957
u012253957 你看下注解@Service使用的是spring的还是dubbo的注解,两者好像有细微的区别
12 个月之前 回复
paker1989
paker1989 补充了
12 个月之前 回复
u012253957
u012253957   2017.01.05 16:40

你看下注解@Service使用的是spring的还是dubbo的注解,两者好像有细微的区别

paker1989
paker1989 看我问题里的第2条
12 个月之前 回复
paker1989
paker1989 这个我知道,就是因为如果用spring的注解,然后在xml用dubbo标签配置成提供者就会报错!
12 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!