give your java apps “the boot” with spring boot and cloud foundry

13
Give Your Java Apps “The Boot” With Spring Boot And Cloud Foundry By: Ryan Baxter @ryanjbaxter 10/17/14

Upload: ryan-baxter

Post on 28-Nov-2014

427 views

Category:

Software


0 download

DESCRIPTION

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

TRANSCRIPT

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

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

By: Ryan Baxter@ryanjbaxter

10/17/14

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

Who Am I? @ryanjbaxter http://ryanjbaxter.com IBMer for 6 years Developer Advocate for IBM

Bluemix Likes using Java Not a Spring expert

2

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

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

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

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

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

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

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

Cloud Foundry

6

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

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

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

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

8

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

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

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

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

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

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

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

Resources Spring Boot Yeoman Generator -

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

12

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

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