我想在Spring中连接Google App Engine用户服务,方法是先创建一个UserServiceFactory bean,然后使用它来获取UserService的实例.
<bean id="googleUserServiceFactory"
class="com.google.appengine.api.users.UserServiceFactory"></bean>
<bean id="googleUserService"
class="com.google.appengine.api.users.UserService"
factory-bean="googleUserServiceFactory"
factory-method="getUserService"></bean>
我很确定这是连接从工厂获得的bean的正确方法,但是我收到此错误:
Error creating bean with name ‘googleUserService’ defined in ServletContext resource [/WEB-INF/hardwire-service.xml]: No matching factory method found: factory bean ‘googleUserServiceFactory’; factory method ‘getUserService’
最佳答案
我通过使用MethodInvokingfactorybean来使其工作.仍然以为我以前做的事情有什么问题让我感到困惑.无论如何:
<bean id="googleUserService"
class="org.springframework.beans.factory.config.MethodInvokingfactorybean">
<property name="staticMethod"
value="com.google.appengine.api.users.
UserServiceFactory.getUserService">
</property>
</bean>