繁体   English   中英

如何使用Guice注入Google App Engine数据存储区?

[英]How to inject Google App Engine datastore with Guice?

我正试图通过Guice将Google App Engine的数据存储注入我的服务中:

public class FooServiceImpl implements FooService {

    private final DatastoreService datastoreService;

    @Inject
    public FooServiceImpl (DatastoreService datastoreService) {
        this.datastoreService = datastoreService;
    }
}

但是当我尝试运行它时,我收到以下错误:

没有绑定com.google.appengine.api.datastore.DatastoreService的实现。

@Provides方法添加到您的模块:

@Provides
DatastoreService provideDatastoreService(){
    return DatastoreServiceFactory.getDatastoreService();
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM