Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code! Brought to you in partnership with ZeroTurnaround.
Deploying Spring applications to CloudFoundry.com
really is as easy as SpringSource
say it is.
being approved for a Cloud Foundry beta account, the first stage is to
install Cloud Foundry support into STS or Eclipse. Christian Dupuis has
an excellent blog post
on how to achieve this, so I won't re-iterate what he has already said.
deploy and run an application using a datasource, MySQL in my case,
requires a bit more effort than deploying a standalone application, but
literally very little.
deploy an application with a datasource, you must first declare which
datasource to use. In Eclipse, open up the Cloud Foundry server and
press the "Add" button on the services pane.
On the following screen, select a name and type for the datasource.
Press the "Finish" button and the datasource is registered.
registering a datasource, you need to tell the application which
datasource to use. This is as straightforward as dragging the
datasource onto the "Application Services" panel for the Cloud Foundry
all the configuration that is needed for the server. Before deploying
an application though, a couple of changes are needed to specify which
datasource is required.
I'm deploying a Spring application, I need to change the application
context file to point to the new Cloud Foundry database rather than a
local database. The nice thing about using a Cloud Foundry database is
that database credentials are not needed, all that is needed is to
change the datasource bean configuration in the servlet-context.xml
For a local deployment, a datasource configuration would look something like:
To configure this to use a Cloud Foundry MySQL database, the datasource configuration would look like:
3.1 contains a new profiles feature to allow both of these
configurations to be stored within the same context file. On Spring 3
however this feature is not available so the context file needs to
either contain the regular bean dataSource definition or the new cloud
To access the new cloud tag, the servlet-context.xml needs changing to access the cloud namespace.
deploy the application, one final change is needed to add Cloud Foundry
support. This is achieved by adding a dependency to Cloud Foundry in
the applications pom.xml file.
After making these changes, the Cloud Foundry application can be deployed and started and stopped using the controls within STS.
The Java Zone is brought to you in partnership with ZeroTurnaround. Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code!