Objective
Grails, as the new force of the WEB framework, has been accepted by more and more developers. and Google App Engine (GAE) as a cloud computing platform for Applications to provide a broad space for expansion. How to make the two brilliant sparks?
With the help of the Gae-enabled plug-in--grails App Engine (the Gae plugin) in Grails, this article uses the JPA interface to take a ToDo application as an example of how to use the Gae plug-in for the development of GAE programs and considerations for development.
The environment used in this article:
Grails 1.3 M1
Google App Engine 1.3.1
app-engine-0.8.10
gorm-jpa-0.7.1
Environment construction
Please download the GAE SDK for Java and Grails first. Unzip the downloaded zip to the appropriate location and set the environment variables Appengine_home and grails_home.
Use the Grails Create-app AppName to create a grails project.
Install the GAE plugin in your project: Grails install-plugin app-engine, Data persistence selection JPA. This command will perform the following tasks:
Uninstall the Hibernate,tomcat plug-in; Install the GORM-JPA plugin.
Install the GORM-JPA plug-in.
Create under AppName \grails-app\conf:
Datastore-indexes.xml: The related configuration of the data store index, by default, the index is automatically created
Persistence.xml: Persistent Configuration
Create the artifacts, scaffolding, and war three directories under AppName \src\templates, which have domain class, controller/views, and web.xml template files respectively.
Create Userhome\.grails\1.3.0.m1\projects\appname\plugins\gorm-jpa-0.7.1\src \groovy\org\grails\jpa\ Jpapluginsupport.groovy, which is the most critical class of Plug, encapsulates JPA-related operations, and the methods invoked in Controller are passed through this class.
Once the environment is ready, performing grails App-engine run creates the following:
Copy the required Jar of GAE to AppName \ web-app \ web-inf\lib directory;
Create plugin directories, Grails.xml, Applicationcontext.xml, web.xml under AppName \ Web-app \ Web-inf