We know that using the Grails class creation tool such as "Grails Create-domain-class" in a grails project can help us create classes such as domain, service, and controller and their test classes and others. As a result, we often use these tools in our grails projects to help us create classes instead of creating them directly. Ahead, we've already integrated the Grails project into eclipse, so how do we create these objects on the Eclipse development platform?
On the Grails official website, there is a description of this, detailing how to use these tools on eclipse, and I'll put this in the following sections:
You can configure grails as an external tool (External Tool), and then you can create domain objects, in eclipse:
1. Select "Run > External Tools > External tools ...";
2. Enter a name, for example: Grails;
3. Find Grails.bat (or grails under *nix) in the file system;
4. Set the working directory to ${project_loc};
5. Parameter set to ${string_prompt};
6. In the Refresh tab, set "Refresh resources upon completion" as "project containing the selected resource";
7. In common, select in the "Display in Favorites menu"
Now you can choose Grails, such as the external tool behind the Drop-down button (that is, the icon that runs a smaller box), for example:
1. Choose Grails in the Drop-down list of external tools;
2. In the pop-up dialog box input create-domain-class;
3. In the console window according to the prompts to complete the command;
4. Open the newly created class in Grails-app/domain.
This section of the blue font above, to create a domain class as an example, details how to use the Eclipse tool to create various classes of grails projects.
However, the above work is still rough, because we want to create a domain class or other classes, it takes about four steps to complete:
The first step is to select the Grails button
The second step is to enter the "Create-domain-class" command
The third step is to enter a class name such as "User"
Step Fourth Click "OK"