Give Your Java Apps “The Boot” With 
Spring Boot And Cloud Foundry 
By: Ryan Baxter 
@ryanjbaxter 
10/17/14
Who Am I? 
 @ryanjbaxter 
 http://ryanjbaxter.com 
 IBMer for 6 years 
 Developer Advocate for IBM 
Bluemix 
 Likes using Java 
 Not a Spring expert 
1
Spring 
 Great set of tools for enterprise Java developers 
 Web, Data, Social, Security, AMQP, Solr, Redis, Mobile, and 
many many more… 
 Each one has its own configuration and setup 
 Some have multiple ways of achieving the same thing 
 Getting multiple Spring projects to work together can 
be challenging 
2
Spring Boot 
 Inspired by micro-frameworks 
 Very opinionated, meaning it provides defaults 
 Favors convention over configuration 
 Works as a plugin with your existing build tools (Maven 
or Gradle) 
 Easy integration with Spring projects using “starter 
dependencies” 
 Has a CLI for prototyping with Groovy 
3
Getting Started With Spring Boot 
 http://start.spring.io 
 Inherit from the Spring Boot parent POM (Maven) 
 Add the Spring Boot plugin 
 Create a class with a “public static void main” method 
public class App { 
public static void main(String[] args) throws Exception { 
SpringApplication.run(App.class, args); 
} 
} 
4
Cloud Foundry 
5
Getting Started With Cloud Foundry 
 Need a Cloud Foundry instance 
 Public hosted options: IBM Bluemix and Pivotal Web Services 
 Primary way of interacting is with a CLI 
$ cf create-service <- create services for app 
$ cf push <- deploy app binary to Cloud Foundry 
$ cf bind-service <- Bind service to app 
$ cf start <- start app 
$ cf scale <- scale app 
6
Using Services 
 Services bound to your application are exposed via an 
environment variable called VCAP_SERVICES 
{"cleardb":[{ 
"name":"todos-mysql", 
"label":"cleardb", 
"plan":"spark", 
"credentials":{ 
"uri":"mysql://user:pass@mysqldb.com", 
"username":"user", 
"password":"pass" 
} 
} 
] 
} 
7
Spring Cloud Connectors 
 Helps with the doing the mundane tasks of accessing 
your services in the cloud 
 Services are exposed via an environment variable 
called VCAP_SERVICES 
 Parse JSON to access data 
 Can be extended for your own services 
 Works with both plain Java apps as well as Spring 
apps 
8
Cloud Foundry Build Plugins 
 All functionality of the CLI in a plugin for Maven and 
Gradle 
 Ideal because you can do consistent deployments 
using a simple command 
 Great for continuous integration and delivery of Java 
projects 
9
Resources 
 Cloud Foundry - http://docs.cloudfoundry.org/ 
 Spring Boot - http://projects.spring.io/spring-boot/ 
 Spring Guides - http://spring.io/guides <- ALL USING 
SPRING BOOT 
 Spring Cloud Connectors - http://cloud.spring.io/spring-cloud- 
connectors/ 
 Cloud Foundry Build Plugins - 
https://github.com/cloudfoundry/cf-java-client 
10
Resources 
 Spring Boot Yeoman Generator - 
https://github.com/ryanjbaxter/generator-sb 
 Slides - http://www.slideshare.net/RyanBaxter 
11
Thank you. 
$ cf push today: www.bluemix.net

Give Your Java Apps “The Boot” With Spring Boot And Cloud Foundry

  • 1.
    Give Your JavaApps “The Boot” With Spring Boot And Cloud Foundry By: Ryan Baxter @ryanjbaxter 10/17/14
  • 2.
    Who Am I?  @ryanjbaxter  http://ryanjbaxter.com  IBMer for 6 years  Developer Advocate for IBM Bluemix  Likes using Java  Not a Spring expert 1
  • 3.
    Spring  Greatset of tools for enterprise Java developers  Web, Data, Social, Security, AMQP, Solr, Redis, Mobile, and many many more…  Each one has its own configuration and setup  Some have multiple ways of achieving the same thing  Getting multiple Spring projects to work together can be challenging 2
  • 4.
    Spring Boot Inspired by micro-frameworks  Very opinionated, meaning it provides defaults  Favors convention over configuration  Works as a plugin with your existing build tools (Maven or Gradle)  Easy integration with Spring projects using “starter dependencies”  Has a CLI for prototyping with Groovy 3
  • 5.
    Getting Started WithSpring Boot  http://start.spring.io  Inherit from the Spring Boot parent POM (Maven)  Add the Spring Boot plugin  Create a class with a “public static void main” method public class App { public static void main(String[] args) throws Exception { SpringApplication.run(App.class, args); } } 4
  • 6.
  • 7.
    Getting Started WithCloud Foundry  Need a Cloud Foundry instance  Public hosted options: IBM Bluemix and Pivotal Web Services  Primary way of interacting is with a CLI $ cf create-service <- create services for app $ cf push <- deploy app binary to Cloud Foundry $ cf bind-service <- Bind service to app $ cf start <- start app $ cf scale <- scale app 6
  • 8.
    Using Services Services bound to your application are exposed via an environment variable called VCAP_SERVICES {"cleardb":[{ "name":"todos-mysql", "label":"cleardb", "plan":"spark", "credentials":{ "uri":"mysql://user:[email protected]", "username":"user", "password":"pass" } } ] } 7
  • 9.
    Spring Cloud Connectors  Helps with the doing the mundane tasks of accessing your services in the cloud  Services are exposed via an environment variable called VCAP_SERVICES  Parse JSON to access data  Can be extended for your own services  Works with both plain Java apps as well as Spring apps 8
  • 10.
    Cloud Foundry BuildPlugins  All functionality of the CLI in a plugin for Maven and Gradle  Ideal because you can do consistent deployments using a simple command  Great for continuous integration and delivery of Java projects 9
  • 11.
    Resources  CloudFoundry - http://docs.cloudfoundry.org/  Spring Boot - http://projects.spring.io/spring-boot/  Spring Guides - http://spring.io/guides <- ALL USING SPRING BOOT  Spring Cloud Connectors - http://cloud.spring.io/spring-cloud- connectors/  Cloud Foundry Build Plugins - https://github.com/cloudfoundry/cf-java-client 10
  • 12.
    Resources  SpringBoot Yeoman Generator - https://github.com/ryanjbaxter/generator-sb  Slides - http://www.slideshare.net/RyanBaxter 11
  • 13.
    Thank you. $cf push today: www.bluemix.net