【问题标题】:How can I use Interface type object in Grails Domain Class如何在 Grails 域类中使用接口类型对象
【发布时间】:2011-10-26 21:03:33
【问题描述】:

在 Grails 中,Domain 类与数据库表的变量映射。

我想使用接口类型的对象。我想使用依赖注入。

请帮帮我!我不想映射到数据库表!

class User{
  String name
  UserService userService
}

interface UserService{
}

如果使用此代码,我会遇到错误消息。 “无法映射 UserService”

【问题讨论】:

    标签: grails interface dependency-injection dependencies code-injection


    【解决方案1】:

    你需要mark it as transient

    class User{
      String name
      UserService userService
      static transients = ['userService']
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-31
      • 1970-01-01
      • 2017-08-03
      相关资源
      最近更新 更多