[英]Exported service not injecting in my bundle in Spring Dynamic Modules
I am using Spring Dynamic Modules for the first time. 我是第一次使用Spring动态模块。 I have tried to expose a service (simple listofValuesDAO Bean) through a bundle and am trying to inject it in another bundle to use the bean.
我尝试通过捆绑包公开服务(简单的listofValuesDAO Bean),并尝试将其注入另一个捆绑包中以使用Bean。 Below is configuration tag in osgi-context.xml of Bundle1 through which service was exposed:
下面是Bundle1的osgi-context.xml中的配置标签,通过该标签公开了服务:
<osgi:service ref="listOfValuesDAO" auto-export="interfaces"/>
and I am trying to fetch it in Bundle2 through below tag in osgi-context.xml: 我正在尝试通过osgi-context.xml中的以下标记在Bundle2中获取它:
<osgi:reference id="listOfValuesDAO" interface="com.dao.IListOfValuesDAO" />
The issue is that when I try to inject it in my bean in Bundle2 using below configuration: 问题是,当我尝试使用以下配置将其注入Bundle2的bean中时:
<bean id="exportServiceImpl" class="com.service.impl.ExportServiceImpl">
<property name="listOfValuesDAO" ref="listOfValuesDAO"/>
</bean>
System throws below exception: 系统抛出以下异常:
Exception in thread "SpringOsgiExtenderThread-85"org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'exportServiceImpl' defined in URL [bundle://325.16:0/META-INF/spring/module-context.xml]:
Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'listOfValuesDAO' of bean class [com.service.impl.ExportServiceImpl]:
Bean property 'listOfValuesDAO' is not writable or has an invalid setter method. Did you mean 'listOfValuesDao'?
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1396)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
Below is property in my ExportServiceImpl Class: 以下是我的ExportServiceImpl类中的属性:
public class ExportServiceImpl implements IExportService {
IListOfValuesDAO listOfValuesDao;
public void setListOfValuesDao(IListOfValuesDAO listOfValuesDao) {
this.listOfValuesDao = listOfValuesDao;
}
public IListOfValuesDAO getListOfValuesDao() {
return listOfValuesDao;
}
}
Could someone please help me in resolving this issue? 有人可以帮我解决这个问题吗?
It seems to be a problem with case inconsistency: listOfValuesDao
and listOfValuesDAO
are different names. 大小写不一致似乎是一个问题:
listOfValuesDao
和listOfValuesDAO
是不同的名称。
You use the first version in the Service, and the second in the XML bean definition. 您在服务中使用第一个版本,在XML bean定义中使用第二个版本。 Try:
尝试:
<bean id="exportServiceImpl" class="com.service.impl.ExportServiceImpl">
<property name="listOfValuesDao" ref="listOfValuesDao"/>
</bean>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.