DIを持つために私のgwtアプリケーションにdagger2を追加しようとしています。これまでのところ、私はpom.xml
GWTアプリケーションでdagger2を統合する方法は?
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-gwt</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>com.google.auto.factory</groupId>
<artifactId>auto-factory</artifactId>
<version>1.0-beta3</version>
</dependency>
2)で次の依存関係を追加しました)は、次の手順 を踏襲しているが、次のコード行を追加することで、GWTモジュールMyApp.gwt.xml
で短剣依存性を継承します。
<inherits name="dagger.Dagger" />
3)作成コンポーネントクラス。
import javax.inject.Singleton;
import com.google.gwt.event.shared.EventBus;
import dagger.Component;
@Singleton
@Component(modules = AppModule.class)
public interface AppComponent {
EventBus eventBus();
}
4)作成したモジュールクラス
import javax.inject.Singleton;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.event.shared.SimpleEventBus;
import dagger.Module;
import dagger.Provides;
@Module
public class AppModule {
@Provides
@Singleton
SimpleEventBus provideSimpleEventBus() {
return new SimpleEventBus();
}
@Provides
EventBus provideEventBus(SimpleEventBus bus) {
return bus;
}
}
私はAppEntryPoint
AppComponent component = DaggerAppComponent.builder()....build();
でモジュールをビルドしようとしていたときに最後に、私はどこでもmvn compile
またはmvn gwt:compile
後に生成されたクラスDaggerAppComponent
を見つけることができません。私はgwt-maven-plugin
をorg.codehaus.mojo
から使用しています。その明確な私は設定で何かを見逃しているが、正確に何かを把握することはできません。
でフルセットアップ' DaggerChatComponent'は....あなたがそれらの2アップを混在さを見ることができますか? –
タイプミスが修正されました。 – Ajax
ソースファイルは生成されていますか? –