如何使用maven在命令行运行grails generate-controller? [英] How to run grails generate-controller from command line with maven?
问题描述
我正在寻找一种从命令行为mavenized grails 2.1.0项目(即。grails-maven-plugin 2.1.0)运行generate-controller的方法。我已经尝试了以下内容:
mvn grails:generate-controller
- 运行时这我得到一个错误说java.lang.IllegalStateException:用户输入未启用,无法获得输入流。出于某种原因,grails似乎无法从控制台读取(以获取域类的名称)。
mvn grails:execgrails:generate-controller
- 这会导致 org.codehaus.groovy.grails.cli.ScriptNotFoundException
是否有方法通过命令行参数指定域类的名称 - 即。例如 mvn generate-controller -DclassName = my.domain.class.name
?
这并不一定直观,但一般来说 mvn grails:help 很有用。
有关创建域的帮助类和控制器
mvn grails:help -Ddetail = true -Dgoal = generate-controller
mvn grails:help -Ddetail = true -Dgoal = create-domain-class
示例域类和控制器
收到每条评论的更新:如果您碰巧使用MS Windows,请引用
-DdomainClassName 参数值。
mvn grails:create -domain-class -DdomainClassName = com.example.Test
mvn grails:generate-controller -DdomainClassName = com.example.Test
[UPDATE]
公然广告,但我会创建一个secon d视频为Maven和Grails整合,因为您不是唯一拥有类似问题的人。第一个可以在这里找到,非常通用,适合初学者。
希望它有帮助。
I'm looking for a way to run "generate-controller" from the command line for a mavenized grails 2.1.0 project (ie. grails-maven-plugin 2.1.0). I have tried the following:
mvn grails:generate-controller
- when running this I get an error saying "java.lang.IllegalStateException: User input is not enabled, cannot obtain input stream". For some reason, grails appears to not be able to read from the console (to obtain the name of the domain class).- http://jira.grails.org/browse/MAVEN-172 describes this error; I tried both solutions mentioned here (deleting the grails project cache and running mvn clean) but neither solved the problem
mvn grails:exec "grails:generate-controller"
- this results in aorg.codehaus.groovy.grails.cli.ScriptNotFoundException
Is there a way to specify the name of the domain class via command-line parameter - ie. something like mvn generate-controller -DclassName=my.domain.class.name
?
It's not necessarily intuitive, but in general mvn grails:help is useful.
For help about creating domain classes and controllers
mvn grails:help -Ddetail=true -Dgoal=generate-controller
mvn grails:help -Ddetail=true -Dgoal=create-domain-class
Sample domain class and controller
UPDATE per comments received : If you happen to use MS Windows, please quote the
-DdomainClassName argument values below.
mvn grails:create-domain-class -DdomainClassName=com.example.Test
mvn grails:generate-controller -DdomainClassName=com.example.Test
[UPDATE]
Blatant advertising, but I will create a second video for Maven and Grails integration soon, as you're not the only one with similar questions. The first one can be found here, very generic and for starters.
Hope it helps.
这篇关于如何使用maven在命令行运行grails generate-controller?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!