【问题标题】:Grails scaffolding does show nothingGrails 脚手架没有显示任何内容
【发布时间】:2021-08-09 21:36:02
【问题描述】:

我使用 grails 2.4.4

我在 BuildConfig 中添加了依赖项:

dependencies {
    test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"
    compile "org.grails.plugins:scaffolding:2.1.2"
}

并添加插件:

plugins {
    build ":tomcat:7.0.55"
    compile ":scaffolding:2.1.2"
    compile ':cache:1.1.8'
    compile ":asset-pipeline:1.9.9"

    runtime ":hibernate4:4.3.6.1" // or ":hibernate:3.6.10.18"
    runtime ":database-migration:1.4.0"
    runtime ":jquery:1.11.1"
}

创建域人员:

package person

class Person {

    static constraints = {
    }

    String name
}

和控制器:

package person

class PersonController {

    static scaffold = Person
}

也尝试使用:static scaffold = true,同样不行。我尝试删除我的包目标。

但在我的网址 (http://localhost:8090/grails-com.learning/person) 中我什么也没看到

没有插件:

【问题讨论】:

  • grails-com.learning是应用的名字吗?
  • 是的)))))))))
  • 我的插件中没有看到支架插件
  • “我没有在我的插件中看到支架插件” - 如果您的意思是在您的 BuildConfig.groovyplugins{} 块中,它确实在您显示的代码中。 compile ":scaffolding:2.1.2".

标签: java grails groovy scaffolding


【解决方案1】:

https://github.com/jeffbrown/adamscaffolding查看项目。

grails-app/conf/BuildConfig.groovy#L49-L75

dependencies {} 块中的脚手架插件就不用提了,plugins {} 块就是表达的地方)

dependencies {
    // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.
    // runtime 'mysql:mysql-connector-java:5.1.29'
    // runtime 'org.postgresql:postgresql:9.3-1101-jdbc41'
    test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4"
}

plugins {
    // plugins for the build system only
    build ":tomcat:7.0.55"

    // plugins for the compile step
    compile ":scaffolding:2.1.2"
    compile ':cache:1.1.8'
    compile ":asset-pipeline:1.9.9"

    // plugins needed at runtime but not for compilation
    runtime ":hibernate4:4.3.6.1" // or ":hibernate:3.6.10.18"
    runtime ":database-migration:1.4.0"
    runtime ":jquery:1.11.1"

    // Uncomment these to enable additional asset-pipeline capabilities
    //compile ":sass-asset-pipeline:1.9.0"
    //compile ":less-asset-pipeline:1.10.0"
    //compile ":coffee-asset-pipeline:1.8.0"
    //compile ":handlebars-asset-pipeline:1.3.0.3"
}

grails-app/domain/person/Person.groovy

package person

class Person {

    static constraints = {
    }

    String name
}

grails-app/controllers/person/PersonController.groovy

package person

class PersonController {

    static scaffold = Person 

}

该脚手架的行为符合预期。

【讨论】:

  • 我已经尝试过使用不依赖的脚手架,它也不起作用(
  • “我已经尝试过使用没有依赖关系的脚手架,它也不起作用” - 脚手架插件在 Grails 2 中确实可以工作,而不会在 dependencies 块中表达对它的依赖。在 Grails 2 中,表达这种依赖关系的方法是在 BuildConfig.groovyplugins{} 块中。对于 Grails 3 及更高版本,将使用不同的语法,它将位于 build.gradle 中,但对于 Grails 2.4.4 项目,BuildConfig.groovyplugins{} 块中的 compile ":scaffolding:2.1.2" 是您想要的。跨度>
  • 如果你可以分享一个与我为你创建的项目类似的项目,但能证明你正在谈论的问题,我很乐意向你发送 PR 来修复它或描述任何问题.
  • 谢谢你对我的帮助已经够多了,问题出在我的设置上。如果你真的很有趣,你可以看看我的学习项目github.com/AlexandarVysotskiy/grails-learning branch LESSON-4
  • 之前你说应用名称是grails-com.learning。该项目称为grails-learning。 404 是因为您将请求发送到错误的 url 吗?
猜你喜欢
  • 1970-01-01
  • 2020-03-24
  • 2014-07-21
  • 2016-02-19
  • 2020-06-16
  • 2021-02-05
  • 2018-10-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多