Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Bootify your spring application

7,820 views

Published on

Introduction to Spring Boot.

Published in: Software
  • Sex in your area is here: ♥♥♥ http://bit.ly/39sFWPG ♥♥♥
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Follow the link, new dating source: ❶❶❶ http://bit.ly/39sFWPG ❶❶❶
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • I've been struggling with maths for the past 2 years now. In the first mock paper I took, I got a 'U' grade. At this point, I felt hopeless. How was I ever going to pass my maths?! I did a Google search and came across Jeevan's stuff on Youtube. I was in a desperate situation so I had no choice but to purchase your material... Jeevan's resources are amazing. They have really helped me out. I am much more confident with my maths and I am able to answer past papers within the time limit. I recently had a mock exam at school and I achieved a 'D' grade! A massive improvement since my last score. If I continue to make this progress, there is no doubt that I will achieve my pass grade in my final exam. Thanks for your amazing resources Jeevan. They are so much better than the other revision guides I wasted money on! ➤➤ https://bit.ly/33W8jmf
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • How long does it take for VigRX Plus to start working? ♥♥♥ http://t.cn/Ai88iYkP
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Did you know that once you lose your Ex, there is still a good chance you can get them back? Learn how ●●● http://t.cn/R50e2MX
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Bootify your spring application

  1. 1. #JCConf Bootify Your Spring Applications Jimmy Lu Digital River, Inc.
  2. 2. #JCConf Agenda • Brief Introduction to Spring Boot • Getting Started with Spring Boot • Features and Facilities Provided by Spring Boot • Micro Services with Spring Boot
  3. 3. #JCConf What is Spring Boot? • Takes an opinionated view of building production-ready Spring applications • Spring Boot favors convention over configuration and is designed to get you up and running as quickly as possible • Spring Boot helps developers to “boot” up Spring applications faster
  4. 4. Spring IO Platform - http://spring.io/platform
  5. 5. #JCConf Features • Provide a radically faster and widely accessible getting started experience for all Spring development. • Create stand-alone Spring applications • Embed Tomcat or Jetty directly (no need to deploy WAR files) • Provide opinionated 'starter' POMs to simplify your Maven configuration • Automatically configure Spring whenever possible • Provide production-ready features such as metrics, health checks and externalized configuration • Absolutely no code generation and no requirement for XML configuration
  6. 6. #JCConf Who is Using Spring Boot? • Spring’s official website – http://spring.io – project sagan https://github.com/spring- io/sagan – all user guides http://spring.io/guides • Companies who use Spring: Netflix
  7. 7. #JCConf Getting Started with Spring Boot • Install Spring Boot CLI – GVM • $ gvm install springboot – Homebrew • $ brew tap pivotal/tap • $ brew install springboot – Manually
  8. 8. #JCConf Your First Spring Boot Application • Only 113 characters, it is tweetable! @RestController class ThisWillActuallyRun { @RequestMapping("/") String home() { "Hello World!" } } // $ spring run ThisWillActuallyRun.groovy
  9. 9. #JCConf // build.gradle buildscript { repositories { mavenCentral() maven { url "http://repo.spring.io/snapshot" } maven { url "http://repo.spring.io/milestone" } } dependencies { classpath("org.springframework.boot:spring-boot-gradle- plugin:1.1.8.RELEASE") } } apply plugin: 'java' apply plugin: 'spring-boot’
  10. 10. #JCConf // build.gradle cont. repositories { mavenCentral() maven { url "http://repo.spring.io/snapshot" } maven { url "http://repo.spring.io/milestone" } } dependencies { compile("org.springframework.boot:spring-boot-starter-web") testCompile("org.springframework.boot:spring-boot-starter-test") }
  11. 11. #JCConf // Appliation.java. @RestController @EnableAutoConfiguration public class Example { @RequestMapping("/") String home() { return "Hello World!"; } public static void main(String[] args) throws Exception { SpringApplication.run(Example.class, args); } }
  12. 12. #JCConf Spring Boot Magic • Starter POMs • Maven/Gradle plugins • The main method • Auto-configuration
  13. 13. #JCConf Starter POMs • spring-boot-starter-parent (maven) – Provides default plugins, dependencies, and configurations • Java 6 • UTF-8 encoding • Testing frameworks (JUnit, Hamcrest, Mockito) • Resource filters • exec plugin, surefire, Git commit ID, shade – Can be overriden in the child pom.xml
  14. 14. #JCConf Starter POMs • spring-boot-starter-* – A set of convenient dependency descriptors – contain a lot of the dependencies that you need to get a project up and running quickly and with a consistent, supported set of managed transitive dependencies – Ex. spring-boot-starter-web – Whole list: http://bit.ly/1uMCNUg
  15. 15. #JCConf Maven/Gradle Plugin • Provides goals and tasks – ‘Run’ Spring Boot applications – ‘repackage’ executable jar/war
  16. 16. #JCConf The main method • Java convention for an application entry point • Delegates to Spring Boot’s SpringApplication class by calling run – Initialize required elements of spring container like ApplicationContext.
  17. 17. #JCConf Auto Configuration • @EnableAutoConfiguration – @EnableAutoConfiguration(exclude={DataSourceAutoConfigura tion.class}) • META-INF/spring.factories • Classpath dependencies detection • @Conditional* annotations – @ConditionalOnMissingBean(DataSource.class) – @ConditionalOnClass(EmbeddedDatabaseType.class)
  18. 18. #JCConf Auto Configuration – Spring Security • Add spring-boot-starter-security as your application’s dependency • Start the application and you will get – HTTP basic authentication – A single user with username ‘user’ and a random password which is printed on the console. Ex. 78fa095d-3f4c-48b1-ad50-e24c31d5cf35 • Add @EnableWebSecurity to a bean if you want to switch off default configurations.
  19. 19. #JCConf Philosophy & Programming Strategy • Only write code that you need to • Gradually replacing auto-configuration • This means that it ships with useful defaults out of the box that may be overriden, if necessary – ex. if you add your own DataSource bean, the default embedded database support will back away.
  20. 20. #JCConf Problem • There is no comprehensive documentation about all the options • The code in org.springframework.boot.autoconfigure.* packages is a good starting point – e.g. server.port is bound to a field in org.springframework.boot.autoconfigure.web. ServerProperties.
  21. 21. #JCConf Production Ready Features • spring-boot-starter-actuator – Application information – Health information – Monitoring and Management • HTTP • JMX • Remote Shell – Metrics – Whole endpoint list: http://bit.ly/1tPih1u
  22. 22. #JCConf Metrics Example { “counter.status.200.root”: 1, “mem”: 228864, “mem.free”: 189391, “processors”: 4, “uptime”: 26848, …………… }
  23. 23. #JCConf Deployment • Executable jar/war (fat jar/war) – Embedded tomcat or jetty • Normal war file • JEE application server – http://bit.ly/1v3jc2j • Cloud (PaaS) – Cloud Foundry – Heroku
  24. 24. #JCConf Custom & Extend Spring Boot • External configurations – .properties – .yml – http://bit.ly/1wqeWV3 • Auto-configuration • Health indicator • Application info • Metrics
  25. 25. #JCConf Microservices In short, the microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities and independently deployable by fully automated deployment machinery. There is a bare minimum of centralized management of these services, which may be written in different programming languages and use different data storage technologies. – “Martin Fowler”
  26. 26. #JCConf Microservices • Spring Boot is just a great tool to fit into microservices development • Spring Boot makes you think about microservics architecture with production features it provided at the beginning of development
  27. 27. #JCConf Microservices Demo - UrlShortener • Spring Boot – Spring Data Redis – Spring Cloud Starters • Spring Cloud – Netflix • Eureka • Hystrix – http://bit.ly/1AwW5u1
  28. 28. #JCConf “Working with Spring Boot is like pair- programming with the Spring developers.”
  29. 29. #JCConf 工商服務 • Digital River 榮獲 2014 年臺北幸福企業獎 項 – http://bit.ly/1sDAEnn – jilu@digitalriver.com • 幸福企業就業博覽會 – http://on.fb.me/1ubvpjp
  30. 30. #JCConf Q&A

×