0

gwt(requestfactoryを使用)とSpringでこのエラーが発生します

org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [org.calibra.server.service.AccountService] is defined: expected single bean but found 0: 
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:271)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1101)
at org.calibra.server.SpringServiceLocator.getInstance(SpringServiceLocator.java:24)
at com.google.web.bindery.requestfactory.server.LocatorServiceLayer.createServiceInstance(LocatorServiceLayer.java:56)

私のサービスロケーター

public class SpringServiceLocator implements ServiceLocator {
    @Override
    public Object getInstance(Class<?> clazz) {
        ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(                
            RequestFactoryServlet.getThreadLocalServletContext());
        return context.getBean(clazz);
    }
}

私の春の奉仕

@Service
public class AccountServiceImpl implements AccountService{
     @Override
     public void addNewAccount(Account account) {
       ...
     }

     @Override
     public List<Account> loadAllAccounts() {
        ...
     }

}

Gwt requestContext、私の春のサービスを参照

@Service(value=AccountService.class, locator=SpringServiceLocator.class)
public interface AccountRequest extends RequestContext {

    Request<Void> addNewAccount(AccountProxy account);

    Request<List<AccountProxy>> loadAllAccounts();

}

私のweb.xml

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
    <servlet-name>gwtRequest</servlet-name>
    <servlet-class>com.google.web.bindery.requestfactory.server.RequestFactoryServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>gwtRequest</servlet-name>
    <url-pattern>/gwtRequest</url-pattern>
</servlet-mapping>

<welcome-file-list>
    <welcome-file>welcomeGWT.html</welcome-file>
</welcome-file-list>

AccountService Bean を 0 にする方法がわかりません。

私はdispatcher-servletに追加しようとしました

<bean id="accountService" class="org.calibra.server.service.AccountServiceImpl"/>

私は同じ結果を得ました

何か案が?

編集:誰かが完全な例を持っていれば、それは役に立つかもしれません.

4

2 に答える 2

0

DispatcherServlet を使用していないように見えるので、 ContextLoaderListener を単独で使用するだけでは十分ではないと思います(持っていますか?)。次の行は私のために働きます:

<filter>
    <filter-name>springRequestContextFilter</filter-name>
    <filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>springRequestContextFilter</filter-name>
    <url-pattern>/gwtRequest</url-pattern>
</filter-mapping>
于 2012-08-16T09:17:52.220 に答える
0

この質問を他のいくつかの場所で見ました。最初に AccountServiceImpl を applicationContext.xml (dispatch-servlet.xml ではなく) で Bean として明示的に定義してみて、それでもエラーが発生するかどうかを確認してください。そうでない場合は、コンポーネントが欠落していることがわかります。 -あなたのアプリケーションコンテキストxmlでスキャンしてください。これは私が当てはまると思います。

お役に立てれば

于 2012-09-06T16:30:22.453 に答える