Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Buzzing the Cloud with CloudBees and Roo

DZone's Guide to

Buzzing the Cloud with CloudBees and Roo

· Cloud Zone ·
Free Resource

See why enterprise app developers love Cloud Foundry. Download the 2018 User Survey for a snapshot of Cloud Foundry users’ deployments and productivity.

Looking to try out CloudBees for your Spring application?

Here is how you can get started quickly with CloudBees Run@Cloud platform.

  1. Get a CloudBees Account
  2. Configure a MySql instance on CloudBees
  3. Build a Spring Roo application
    see script below
  4. Create a cloudbees-web.xml file in WEB-INF
    same directory as web.xml
  5. Add Maven CloudBees Plugin
  6. Build and deploy with Maven
    mvn clean install bees:deploy

 

Roo 1.2.0 Script

Here is a simple item manager application script you can use/customize to create your application

# FOR SPRING ROO 1.2 - Spring Data JPA and Service Layer
 
development mode --enabled true
 
project --topLevelPackage com.gordondickens.roobees --java 6 --projectName roobees
 
jpa setup --provider HIBERNATE --database MYSQL --userName yourmysqluserid --databaseName yourmysqlinstancename --password yourmysqlpasswd
 
entity --class ~.domain.Item --activeRecord false
 
field string --fieldName name --sizeMin 3 --sizeMax 30 --class ~.domain.Item
field string --fieldName description --sizeMax 255 --class ~.domain.Item
 
repository jpa --interface ~.repository.ItemRepository --entity ~.domain.Item
 
service --interface ~.service.ItemService --entity ~.domain.Item
 
web mvc setup
web mvc all --package ~.web
 
logging setup --level DEBUG

 

Roo 1.1.5 Script

Here is a simple item manager application script you can use/customize to create your application

# FOR SPRING ROO 1.1.5
 
development mode --enabled true
 
project --topLevelPackage com.gordondickens.roobees --java 6 --projectName roobees
 
persistence setup --provider HIBERNATE --database MYSQL --userName yourmysqluserid --databaseName yourmysqlinstancename --password yourmysqlpasswd
 
entity --class ~.domain.Item
 
field string --fieldName name --sizeMin 3 --sizeMax 30 --class ~.domain.Item
field string --fieldName description --sizeMax 255 --class ~.domain.Item
 
web mvc setup
web mvc all --package ~.web
 
logging setup --level DEBUG

cloudbees-web.xml

<?xml version="1.0"?>
<cloudbees-web-app xmlns="http://www.cloudbees.com/xml/webapp/1">
  <appid>roobees</appid>
  <context-param>
    <param-name>application.environment</param-name>
    <param-value>prod</param-value>
  </context-param>
</cloudbees-web-app>

Maven CloudBees Plugin

Add the CloudBees repository to the pluginRepositories section.

<pluginRepositories>
  ...
  <pluginRepository>
    <id>bees-plugins-snapshots</id>
    <url>http://repository-cloudbees.forge.cloudbees.com/public-snapshot/</url>
    <releases>
      <enabled>false</enabled>
    </releases>
    <snapshots>
      <enabled>true</enabled>
    </snapshots>
  </pluginRepository>
  ...
</pluginRepositories>

Add the CloudBees Maven plugin to the plugins section.

<plugins>
  ...
  <plugin>
    <groupId>com.cloudbees</groupId>
    <artifactId>bees-maven-plugin</artifactId>
    <version>1.0-SNAPSHOT</version>
    <configuration>
       <!-- your username/appname -->
      <appid>youruserid/roobees</appid>
      <!-- your api key -->
      <apikey>BEBEBE2CEBEBEFBE</apikey>
      <!-- your secret key -->
      <secret>GEE0GERE0E-JE0EQETEHEPET+33MEIEIEI0EEZEEIEE00+</secret>
      <message>Roo ItemManager on CloudBees by Gordon Dickens</message>
    </configuration>
  </plugin>
  ...
</plugins>

 

Database Properties File

Edit the /src/main/resources/META-INF/spring/database.properties file.
Set the database.url to jdbc:cloudbees://yourmysqlinstance.
Set the database.driverClassName to com.cloudbees.jdbc.Driver.

database.username=yourmysqluserid
database.password=yourmysqlpasswd
 
database.url=jdbc:cloudbees://yourmysqlinstancename
database.driverClassName=com.cloudbees.jdbc.Driver

Download the Demo App

The demo app is in Git https://github.com/gordonad/roo-1.2-cloudbees for Spring Roo 1.2.

 

From http://gordondickens.com/wordpress/2011/09/26/buzzing-the-cloud-with-cloudbees-and-roo/

Cloud Foundry saves app developers $100K and 10 weeks on average per development cycle. Download the 2018 User Survey for a snapshot of Cloud Foundry users’ deployments and productivity. Find out what people love about the industry standard cloud application platform.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}