I am new to Grails and I like it very much. I want to place my classes in packages like org.company.project.module.model
. Its quite painful for to me to repeat create-domain-class <package>.<class_name>
. Is there something like "package templates" or can I somehow "enter" (like grails cd org.comopany...
) and then just write Class names (grails Person
will be generated in ./
location)? Is that possible or should I use copy paste
design pattern?
Thanks in advance for any help.
If I understood your question, you are looking for default package name for your domain classes. In your config.groovy
file there is a line saying:
grails.project.groupId = appName
if you give it an appName, Grails will use that as the default package name when it generates the artifacts.
grails.project.groupId = 'com.example.yourpackagename'
If you now create a domain class by default it will locate it under com/example/yourpackagename
.
UPDATE
It is not required to use Grails commands like create-domain-class or other commands to create artifacts. These are all just classes that you can manually create. Just create a file and duplicate it in the same package.
UPDATE
Grails interactive mode (when you type grails) for some of the commands by pressing tab
it will type ahead the unique portion of the package name.
UPDATE for Grails 3.0
The setting has moved into conf/application.yml
:
grails:
profile: web
codegen:
defaultPackage: com.example.yourpackagename
© 2022 - 2024 — McMap. All rights reserved.