Grails3 domain里面使用service

Grails3.2-版可以直接在domain中注入service,在Grails3.2+中默认关闭了自动注入功能

开启方式

  • 方式一

application.groovy中配置全局映射,若没有此脚本需新建

grails.gorm.default.mapping = {
    autowire true
}
  • 方式二

在需要注入beandomain中添加映射

static mapping = {
    autowire true
}
  • 方式三

application.yml中新增或修改配置

---
grails:
    gorm:
        autowire: true

参考

发布了72 篇原创文章 · 获赞 38 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/qq_16165281/article/details/91577506
今日推荐