开发者

How to use google guice appropriately and efficiently

开发者 https://www.devze.com 2023-03-14 09:50 出处:网络
I am working on a web site and we use the Google Guice for the Dependence Inject开发者_C百科ion. Now we just use the guice to inject the constructor of the services implicitly by adding the @Implement

I am working on a web site and we use the Google Guice for the Dependence Inject开发者_C百科ion. Now we just use the guice to inject the constructor of the services implicitly by adding the @ImplementedBy annotation. The code is such as:

@ImplementedBy(ServiceImp.class)
public Interface Service{...}

public ServiceImpl{@Inject constructor()....}

Guice.createInjector().getInstance(Service.class)

I think we may need to set the stage and the scope or other factor involves in the performance. But I am not sure about all of this.

Could anyone share some experience?


I think Best practice section will help you.

0

精彩评论

暂无评论...
验证码 换一张
取 消