O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

Introduction to Spring Boot at SVCC 2017

2.354 visualizações

Publicada em

Spring Boot, the new convention-over-configuration centric framework from the Spring team at Pivotal, marries Spring's flexibility with conventional, common sense defaults to make application development move swiftly and enjoyable. It's ideally suited for building microservices and distributed systems and makes streamlining devops practices simple. Join Pieter Humphrey from the Spring Team or a look at what Spring Boot is, why it's turning heads, why you should consider it for your next application (REST, web, batch, big-data, integration, whatever!) and how to get started.
Silicon Valley Code Camp Presentation:
https://www.siliconvalley-codecamp.com/presenter/2017/pieter-humphrey-28628
Demo: https://www.youtube.com/watch?v=47xNBNd-LLI&t=162s

Publicada em: Tecnologia
  • Seja o primeiro a comentar

Introduction to Spring Boot at SVCC 2017

  1. 1. 1 © 2017 Pivotal Introduction to Spring Boot Pieter Humphrey, Pivotal @pieterhumphrey @springcentral
  2. 2. 2 https://pivotal.io/event/pivotal-cloud-native-roadshow
  3. 3. 3 Agenda  Challenges building non-Boot applications  What is Spring Boot?  Capabilities  Demo
  4. 4. 4 Classpath Hell • A Jar is missing • There is one Jar too many • A class is not visible where it should be
  5. 5. 5 Resolving Classpath Hell Read docs/blogs/copy previous project structure start Download jars Add jars to classpath Write Code Unresolved symbol? build run NoClassDef Found? end Ye s No NoYe s
  6. 6. 6 xx Setup 1. Perform setup operations as “root” 2. Update /etc/hosts with entries for “localhost” 3. Create a new group (oinstall) and user (oracle) 4. Create directories in which Oracle will be installed 5. Add ORACLE_BASE, ORACLE_HOME, MW_HOME, WLS_HOME, WL_HOME, DOMAIN_BASE, DOMAIN_HOME, JAVA_HOME to .bash_profile Post Installation 19.Start WebLogic server 20.Manage and monitor through an administrator console Installation 6. Download the installer 7. Run the installer as “oracle” user 8. Choose Inventory Directory and Operating System Group 9. Choose MIDDLEWARE_HOME 10.Install Configuration 11.Choose a Domain Location 12.Create a Domain using product templates 13.Provide administrator credentials 14.Choose JDK 15.Configure Admin Server 16.Configure Node Manager 17.Configure Managed Servers 18.Configure Clusters
  7. 7. 7 Environment Drift war / ear ConfigurationConfiguration war / ear Dev. Environment Prod. Environment Standard war/ear packaging causes drift across environments App Server classpath App Server classpath
  8. 8. 8 Boilerplate code Every application that accesses a relational database with JDBC needs to configure a JdbcTemplate and a DataSource
  9. 9. 9 Agenda  Challenges building non-Boot applications  What is Spring Boot?  Capabilities  Demo
  10. 10. 10 Spring Boot is an opinionated framework to simplify bootstrapping and development of new Spring Applications
  11. 11. 11 Spring Boot Adoption Source: oss.sonatype.org + spring powered data quality filtering. (e.g. removing our own downloads). Monthly Maven downloads only (no jCenter) 0 5,000,000 10,000,000 15,000,000 20,000,000 25,000,000 Aug-16 Sep-16 Oct-16 Nov-16 Dec-16 Jan-17 Feb-17 Mar-17 Apr-17 May-17 Jun-17 Jul-17 Aug-17 22.2M
  12. 12. 12 Capabilities • Quick start project generation • Automatic project dependency management • Configuration drift prevention • Conditional configuration
  13. 13. 13 Capabilities • Developer Productivity Tooling • Auto-configuration • Monitoring and management endpoints • Microservices-friendliness
  14. 14. 14 Spring Initializr (Quick start project generation)
  15. 15. 15 Spring Initializr is a configurable service to consistently and easily generate a quick start project
  16. 16. 16 • Generates a Spring Boot project structure • Provides a Maven/Gradle build specification • Doesn’t generate application code • You can customize the Spring Initialzr – https://github.com/spring-io/initializr/
  17. 17. 17 Spring Initializr is a configurable service to consistently and easily generate a quick start project
  18. 18. 18 Spring Initializr has three supported interfaces
  19. 19. 19 1.IDE • Eclipse • Intellij
  20. 20. 20 2.Web-based Interface
  21. 21. 21 3.Command Line Interface
  22. 22. 22 Spring Boot starters (Automatic project dependency management)
  23. 23. 23 • ..are virtual packages deployed to Maven central • They pull in other dependencies while containing no code of their own spring-boot-starter-web spring-web spring-boot- starter- tomcat spring-boot- starter- validation spring- webmvc jackson- databind Starters
  24. 24. 24 • Set parent of your pom.xml as spring-boot-starter-parent – Inherit preset version numbers Project pom.xml
  25. 25. 25 Are the version numbers compatible with each other? Is the list of dependencies complete? Starter versions determined by version of Spring Boot used. Dependencies guaranteed to be compatible. Verbose. Non-boot pom.xml with version numbers.Concise. Boot pom.xml without version numbers. Starters vs. current practice
  26. 26. 26 Packaging (Configuration drift prevention)
  27. 27. 27 Boot’s Maven / Gradle plugins produce an executable “fat jar” Application Code Embedded Server Dependent Jars Make Jar not War!
  28. 28. 28 Benefits • No installation of application servers • No setting classpath • Promotes consistency across environments • Easy to CI, CD with • Can be started as Unix services using – init.d – systemd
  29. 29. 29 Post Installation 19.Start WebLogic server 20.Manage and monitor through an administrator console Setup 1. Perform setup operations as “root” 2. Update /etc/hosts with entries for “localhost” 3. Create a new group (oinstall) and user (oracle) 4. Create directories in which Oracle will be installed 5. Add ORACLE_BASE, ORACLE_HOME, MW_HOME, WLS_HOME, WL_HOME, DOMAIN_BASE, DOMAIN_HOME, JAVA_HOME to .bash_profile Installation 6. Download the installer 7. Run the installer as “oracle” user 8. Choose Inventory Directory and Operating System Group 9. Choose MIDDLEWARE_HOME 10.Install Configuration 11.Choose a Domain Location 12.Create a Domain using product templates 13.Provide administrator credentials 14.Choose JDK 15.Configure Admin Server 16.Configure Node Manager 17.Configure Managed Servers 18.Configure Clusters
  30. 30. 30 Profiles (Conditional configuration)
  31. 31. 31 Segregate parts of the application configuration and make it available in certain environments via – Annotations – Properties file
  32. 32. 32 Mark @Component or @Configuration with @Profile to limit when it is loaded.
  33. 33. 33 Check out code from a Version Control System Prod. Configuration Boot Application Prod. Configuration Dev. Configuration Boot Application Dev. Environment Prod. Environment Dev. Configuration Active config Checkout code from source control Build an executable jar Deploy anywhere Configuration activated based on active profile No Code Changes No Configuration Changes It Just Works! Prod. Configuration Active config
  34. 34. 34 Precedence of externalized configuration
  35. 35. 35 Developer Tools (Developer Productivity Tools)
  36. 36. 36 • Automatic restart • LiveReload
  37. 37. 37 • Restarts a running application when files are changed in the classpath • Excludes static resources from restart considerations – /META-INF/resources – /resources – /static – /public – /templates Automatic restart
  38. 38. 38 • Tunnels debugging via HTTP • Remote client provides a local server of port 8000 • Ensure remote app is started with remote debugging enabled (JAVA_OPTS, manifest.yml for CF users) • Check IDE debugger timeouts for slow conns Remote Debugging
  39. 39. 39 • Install the LiveReload plugin into your browser • Boot starts an embedded LiveReload server • Changes to resources trigger a browser refresh automatically Live reload support
  40. 40. 40 Auto Configuration (Developer Productivity Tools)
  41. 41. 41 Application Context Application Code You have H2 in the classpath You don’t have database connection beans configured manually Let me auto- configure H2 datasource and JdbcTemplate You have Thymeleaf in the classpath Let me auto- configure a Thymeleaf template resolver, view resolver, and template engine template resolver view resolver template engine H2 datasource Jdbc Template Automatically configures application based on the classpath classpath jars Auto configuration
  42. 42. 42 Explicitly exclude auto configuration Application Context Application Code @EnableAutoConfiguration(exclude= {DataSourceAutoConfiguration.class}) You have H2 in your classpath You want to explicitly exclude auto-configuration of the DataSoure I’ll step aside. You have Thymeleaf in your classpath Let me auto- configure a Thymeleaf template resolver, view resolver, and template engine template resolver view resolver template engine classpath
  43. 43. 43 Fine – tuning auto configuration Over 300 properties to tweak beans in a Boot application via • Command line arguments • Environment variables • .properties / .yml file
  44. 44. 44 Actuator (Monitoring & Management Endpoints)
  45. 45. 45 Production-ready features such as monitoring and metrics to improve operator efficiency
  46. 46. 46 Actuator Services are exposed through – HTTP endpoints – shell interface – JMX Beans Spring Boot Application Actuator REST endpoint (Spring MVC App) shell interface JMX beans
  47. 47. 47 Actuator endpoints Configuration /beans /autoconfig /env /configprops /controller /beans /loggers /mappings Miscellaneous /shutdown /info /actuator /flyway /liquibase Metrics /health /metrics /trace /dump /auditevents /trace
  48. 48. 48 Demo
  49. 49. 49 Learn More. Stay Connected.  Spring Guides • spring.io/guides  Boot YouTube Playlist • spring.io/video Twitter: twitter.com/springcentral YouTube: spring.io/video LinkedIn: spring.io/linkedin Google Plus: spring.io/gplus

×