Connecting a UserServiceFactory of a Google AppEngine Application with Spring

I wanted to bundle the Google App Engine user service in Spring by first creating a UserServiceFactory bean and then using this to get an instance of 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>

I am sure this is the correct bean connection method you get from factory, but I get this error:

Error creating bean with the name "googleUserService" defined in the ServletContext resource [/WEB-INF/hardwire-service.xml]: No suitable factory method was found: factory bean 'googleUserServiceFactory'; factory method getUserService

It says that the factory method was not found. Can the factory method name be changed?

+3
2

, , MethodInvokingFactoryBean. , , . :

<bean id="googleUserService"
      class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">

       <property name="staticMethod"
                 value="com.google.appengine.api.users.
                            UserServiceFactory.getUserService">
       </property>
</bean>
+2

:

@Configuration
public class AppConfig {

    @Bean
    public UserService userService() {
        return UserServiceFactory.getUserService();
    }
+1

Source: https://habr.com/ru/post/1716928/


All Articles