Rocket to the Cloud Fast with Roo
Join the DZone community and get the full member experience.
Join For FreeWant to build a Spring 3 application FAST and run it on the Cloud? It is incredibly easy to do with Spring Roo and CloudFoundry!
This post on using Postgres on CloudFoundry helped me get started, however I tried using the 1.2.M1 with the CloudFoundry addon, but was unable to install it successfully in either 1.1.5.RELEASE or 1.2.0.M1.
Recently, Spring Roo moved to GitHub
Steps
- Get a Free CloudFoundry Account
- Clone the Spring Roo Git Repository
- Configure GPG/PGP setup
see /spring-roo/readme.txt - Build Spring Roo with Maven
mvn -U clean install -Dgpg.passphrase=yourpassphrase - Link the Roo startup script
see /spring-roo/readme.txt
Creating a Project
- Make a directory for your SimpleItem project
mkdir /SimpleItem - Go to the directory
cd /SimpleItem - Create the script file simpleitem.roo in the /SimpleItem directory
(see the contents below) - Start roo-dev
- Type the command
script --file simpleitem.roo - Go To: http://mysimpleitem.cloudfoundry.com/
The simpleitem.roo script file
development mode --enabled true project --topLevelPackage com.gordondickens.simpleitem --java 6 --projectName SimpleItem jpa setup --provider HIBERNATE --database POSTGRES entity --class ~.domain.Item --testAutomatically --activeRecord false field string --fieldName name --sizeMin 3 --sizeMax 30 --class ~.domain.Item field string --fieldName description --sizeMax 255 --class ~.domain.Item field date --fieldName visitDate --type java.util.Date --notNull --past repository jpa --interface ~.repository.ItemRepository --entity ~.domain.Item service --interface ~.service.ItemService --entity ~.domain.Item finder add --finderName findItemsByName --class ~.domain.Item finder add --finderName findVisitsByDescriptionLike web mvc setup web mvc all --package ~.web web mvc finder all logging setup --level DEBUG perform package download accept terms of use pgp automatic trust # ########### # NOTE: Provide your credentials here, or perform these steps at the Roo prompt # ########### cloud foundry login --email you@mycompany.com --password n00n3w1llgu3ss # ########### # NOTE: The war file is the "--projectName" specified above # ########### cloud foundry deploy --appName mysimpleitem --path /target/SimpleItem-0.1.0.BUILD-SNAPSHOT.war --memory 512 cloud foundry create service --serviceName mysimpleitem-postgres --serviceType postgresql cloud foundry bind service --serviceName mysimpleitem-postgres --appName mysimpleitem cloud foundry start app --appName mysimpleitem # ########### # Go to URL: http://mysimpleitem.cloudfoundry.com/
NOTE CloudFoundry is Public
Since CloudFoundry is public, you may run into an issue deploying the application with the name above. You should change the --projectName to something unique with your name in it such as yourname-simpleitem.
Gunnar Hillert’s Blog explains this well.
Adding CloudFoundry Plugin to Maven
Thanks to Gunnar Hillert’s post, we can add to our project’s Maven pom.xml file the CloudFoundry Plugin.
<plugins> ... <plugin> <groupId>org.cloudfoundry</groupId> <artifactId>cf-maven-plugin</artifactId> <version>1.0.0.M1</version> <configuration> <server>mycloudfoundry-instance</server> <target>http://api.cloudfoundry.com</target> <url>${project.name}.cloudfoundry.com</url> <memory>256</memory> </configuration> </plugin> ... </plugins>
Add CloudFoundry Credentials
Add credentials to our userhome/.m2/settings.xml
<servers> ... <server> <id>mycloudfoundry-instance</id> <username>you@mycompany.com</username> <password>n00n3w1llgu3ss</password> </server> ... </servers>
To push (deploy) the code to CloudFoundry type mvn cf:push
For more plugin details type mvn cf:help
From http://gordondickens.com/wordpress/2011/09/23/rocket-to-the-cloud-fast-with-roo/
Opinions expressed by DZone contributors are their own.
Comments