現在我和get
方法在Key
類中混淆了。 我的問題是關於哪一個get
方法用於下面的代碼。 但是,我找不到合適的方法。當然,我已經檢查過API參考,但是我找不到可能的方法。
請參閱此代碼。get()方法在Key in Guice中
public static void main(String[] args) throws Exception {
Injector injector = Guice.createInjector(
new DatabaseModule(),
new WebserverModule(),
...
);
Service databaseConnectionPool = injector.getInstance(
Key.get(Service.class, DatabaseService.class));
databaseConnectionPool.start();
addShutdownHook(databaseConnectionPool);
Service webserver = injector.getInstance(
Key.get(Service.class, WebserverService.class));
webserver.start();
addShutdownHook(webserver);
}
的第二個參數似乎是T extends V
其中第一個參數是V
。儘管這只是我的假設,那麼Key
類中的哪個方法在此代碼中使用?
是什麼阻止您在任何現代IDE中打開代碼並使用「導航到方法」? – user3707125