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

Preview:

DESCRIPTION

Talk about using Spring Boot and Cloud Foundry to build powerful enterprise Java apps in the cloud.

Citation preview

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

2

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

3

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

4

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);

}

}

5

Cloud Foundry

6

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

7

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"      }    }  ]}

8

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

9

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

10

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

11

Resources Spring Boot Yeoman Generator -

https://github.com/ryanjbaxter/generator-sb Slides - http://www.slideshare.net/RyanBaxter

12

Thank you.$ cf push today: www.bluemix.net

Recommended