Inject in scala object

前端 未结 1 1585
盖世英雄少女心
盖世英雄少女心 2021-01-12 01:36

I\'m using Play framework 2.5 and try to inject WSClient in a scala object used in my controllers.

import play.api.libs.concurrent.Execution.Implicits.defaul         


        
相关标签:
1条回答
  • 2021-01-12 01:50

    You should define MyObject as class and inject wsclient to it:

    class MyObject @Inject()(ws: WSClient) {
        def doSomething() = { /* use wsclient */ }
    }
    
    0 讨论(0)
提交回复
热议问题