0

我使用 google guice 作为 DI 框架将我的接口绑定到不同的实现。服务器运行正常,但每当我尝试调用 Resource 类时,都会发生以下错误。并不是说绑定永远不会起作用,而是大多数时候它都失败了。我不知道我错过了什么。我在下面给出了一些源代码。

模块类

public class ABCModule extends AbstractModule {
@Override
protected void configure() {
    bind(IConnection.class).to(ABCConnection.class);
}

完成注入的资源类

public class Resource {

Logger log = LoggerFactory.getLogger(Resource.class);
private final IContact contact;
private final IContactFolder contactFolder;

@Inject
public MLContact(IConnection con, IContactFolder contactFolder) {
    this.contact = contact;
    this.con = con;
    this.contactFolder = contactFolder;
   }
   //Resource class methods
    ..
     ......
}

我正在使用 guice-3.0.jar

编辑1:

   INFO: Initiating Jersey application, version 'Jersey: 1.17 01/17/2013 04:27 PM'   Aug 8, 2013 9:54:59 AM com.sun.jersey.spi.inject.Errors processErrorMessages
   SEVERE: The following errors and warnings have been detected with resource and/or provider classes:
   SEVERE: Missing dependency for constructor public com.motilink.server.services.MLContact(com.motilink.connector.IContact,com.motilink.connector.IConnection,com.motilink.connector.IContactFolder) at parameter index 0
   SEVERE: Missing dependency for constructor public com.motilink.server.services.MLContact(com.motilink.connector.IContact,com.motilink.connector.IConnection,com.motilink.connector.IContactFolder) at parameter index 1
4

0 回答 0