Grails: Dynamically inject service in domain class

前端 未结 3 1273
独厮守ぢ
独厮守ぢ 2021-02-06 13:33

I need to inject a service based on domain property, so far I came up with the following:

ApplicationHolder.application.getServiceClass(\"package.${property}Serv         


        
3条回答
  •  萌比男神i
    2021-02-06 13:58

    Yes. Services aren't injected into domain objects. If your domain object needs something for a particular use case, let the service that owns that use case invoke the other service on the domain object's behalf.

提交回复
热议问题