开发者

Getting Grails not to create packages from hyphenated app names

开发者 https://www.devze.com 2023-02-23 07:07 出处:网络
If I create a Grails app called a-b-c-d, doing a grails create-domain-class User will result in Grails crea开发者_JAVA百科ting a class User in the sub-directory grails-app/domain/a/b/c/d, giving it th

If I create a Grails app called a-b-c-d, doing a grails create-domain-class User will result in Grails crea开发者_JAVA百科ting a class User in the sub-directory grails-app/domain/a/b/c/d, giving it the package a.b.c.d. How do I prevent Grails from creating these package names?


You should definitely use packages, but you can customize the default package by changing the value of grails.project.groupId in Config.groovy. The default value is appName which is your application name, but you can change it to any value package, e.g. 'com.foo.bar'.

In addition you can specify the package when running a create script, and if you do want to create classes in the default package, you can use this syntax:

grails create-service .Person

and it won't use a package.


I have no idea, this sounds like a bug. There are two obvious workarounds

  • change your app to have a name without dashes
  • don't use the Grails commands create-domain-class, create-controller-class, etc. I never use these commands because they don't actually do anything other than creating the class (and a corresponding empty test class). Personally, I find it easier just to create the class myself than to run the Grails command


You can specify the package when you call the cli command...

grails create-domain-class your.package.name.User
0

精彩评论

暂无评论...
验证码 换一张
取 消