Using Springsource Tool Suite with Google App Engine
Nowadays web application development relies on fast scaffolding based on templates, automated build and deploy tools. In java, you can find tools like ant and maven or leningen to create a stub application by just one command, build and deploy is not more complicated than just issuing two words command line command like maven build…
But when it comes to some frameworks it might be a big struggle to find a build tool that can do all of these, an example is how to fast scaffold a stub Google App Engine application that is going to use spring frame work.
You can find build tools for either Google app engine applications like Google plugin for Eclipse or spring application development provided by Springsource Tool Suite :STS.
There is the Google plugin for STS , but when you create a GAE application it hardly does anything.
One way you can have such application setup quick is using Roo, but for me it sounds a step too far, I want a tool to do scaffolding for me, but not all the views, by the way, project created by Roo can not build in STS out of box.
Some people blogged about creating a GAE stub first then manually add spring jars to the project, this is hardly satisfying as issues of versioning, upgrading are not addressed, and a tool like STS has all the guts of building spring application in it, the thing is just how are we going to do this in our attempted perspective.
Here I am going to document to set up spring framework based google app engine template on STS without using ROO, without adding spring jars manually.
It also applies to application that have been built using spring framework, but not targeting to GAE specifically. Through the same process, you can add GAE support to your application, but there might be some errors you need to sort out before it can be run on GAE.
It starts from a springmvc project template then adding the support of Google AppEngine, in the end from this project you have built-in support from both GAE and spring, you can keep developing it as a spring project and run and debug it in tcServer, also you can run this as GAE project and deploy to GAE is also a click away.
File->New->Spring Template Project->Spring MVC Project
And what you have got is like:
This is a standard springmvc application from the out of box template, if you have already got a spring application, the last step can be ignored and start from the next step.
Right click the project Build path: Add Libraries…, Google App Engine
Add appengine-web.xml to src/main/webapp/WEB-INF/
This has to be added by dropping it from IDE, rather than copying it under file system
Add lib folder to src/main/webapp/WEB-INF/
Add gwt-serlet.jar to src/main/webapp/WEB-INF/lib
Right click the project -> Google->then properties for yourproject window -> Web Application->tick this project has a WAR directory->point it to src/main/webapp
Right click the project again->Google->then properties for yourproject window -> Google-App-Engine, contents in appengine-web.xml should be picked up, and simply tick the box ‘use google app engine’
RunAs maven package(if you run as Google Web Application, it will ask for war packages) to build spring project, now it will be totally fine to debug or deploy this project to App Engine, when run it as Web Application, point war to src/target/ springmvcintegrationwithgae-1.0.0-BUILD-SNAPSHOT.
This means you should be able to run it as both spring project or gae project.
Final project structure will be like:
STS Version : 2.7.1.