How to inject something into a form

后端 未结 1 1849
执念已碎
执念已碎 2021-01-14 08:45

Since play 2.4.0, we can use a DI framework.

I am trying to use DI in my app. I moved my jpa finders from static methods on my models classes to methods in a service

1条回答
  •  抹茶落季
    2021-01-14 09:38

    Play Framework forms are not dependency injectable and have different scope than userService, thus you cannot inject your dependencies into Login form by annotation. Try this:

    public String validate() {
        UserSvc userSvc = Play.application().injector().instanceOf(UserSvc.class);
    }
    

    0 讨论(0)
提交回复
热议问题