Top Banner
| CALLISTAENTERPRISE.SE SPRING BOOT MATS EKHAMMAR 2016-01-27
22

Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

Jun 27, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

| CALLISTAENTERPRISE.SE

SPRING BOOT

MATS EKHAMMAR

2016-01-27

Page 2: Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

•  Simple example •  What is Spring Boot? •  Demo application •  Jarfiles •  Developer Tools •  Configuration from config server •  Actuator •  Wrap up

AGENDA

2

Page 3: Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

•  Simple example - REST service

•  Spring Boot CLI (Command Line Interface) - Groovy files

INTRODUCING SPRING BOOT

Page 4: Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

Spring yyy

config

props

Spring xxx

config

props

SPRING BOOT EMERGING

4

Spring Boot!

props

Spring Security

config

props pom.xml

+ config

Spring Data

config

props

Spring Web

config

props props

pom.xml

Page 5: Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

•  Helps creating Spring Applications

•  Convention over configuration •  Starter POMS - Automatic configuration with sensible defaults - Example: spring-boot-starter-web

•  Features - Monitoring - Metrics - …

WHAT IS SPRING BOOT

5

Page 6: Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

•  ”Getting started” the easy way quickly •  Check out new features in the Spring stack

•  Minimal immediate knowledge of dependencies, configuration, … •  Need to create small autonomous applications (microservices)

•  Distributed system landscape

WHY – WHEN

6

Page 7: Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

•  Rolling two dices

•  REST endpoint -  /roll

•  WEB page URL -  /rolling

•  Eclipse STS (Spring Tool Suite)

DEMO APPLICATION

7

Page 8: Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

•  demo-0.0.1-SNAPSHOT.jar -  big

•  über-jar •  MANIFEST.MF - Main-Class: org.springframework.boot.loader.JarLauncher

JAR FILES

8

Page 9: Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

EXECUTABLE JAR

9

•  ”Script file”

•  pom.xml … <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <executable>true</executable> </configuration> …

Page 10: Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

@SpringBootApplicationpublic class DicesServiceApplication {

public static void main(String[] args){SpringApplication.run(DicesServiceApplication.class, args);

}}

MAIN APPLICATION CLASS

10

Page 11: Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

•  @Configuration •  @ComponentScan

•  @EnableAutoConfiguration

@SPRINGBOOTAPPLICATION

11

Page 12: Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

•  Parent -  version 1.3.2.RELEASE

•  Dependencies -  org.springframework.boot

»  spring-boot-starter-web »  spring-boot-starter-thymeleaf »  spring-boot-starter-test

POM.XML

12

Page 13: Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

•  Dependencies -  org.springframework.boot

»  spring-boot-starter »  spring-boot-starter-tomcat »  spring-boot-starter-validation

-  com.fasterxml.jackson.core »  jackson-databind

-  org.springframework »  spring-web »  spring-webmvc

SPRING-BOOT-STARTER-WEB

13

Page 14: Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

•  Dependencies to turn on - DevTools - Config - Actuator

TURN ON DEPENDENCIES

14

Page 15: Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

•  Automatic restart - Code changes require restart of application

•  LiveReload -  html, javascript, templates, images, stylesheets, …

DEVELOPER TOOLS

15

Page 16: Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

•  Configuration server - Holds configurations for different applications

CONFIGURATION FROM EXTERNAL APPLICATION

16

dices-service config-server

Page 17: Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

•  REST Endpoints -  /beans -  /autoconfig -  /env -  /mappings - … - /health - /metrics -  ...

ACTUATOR

17

Page 18: Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

•  Count dice rolls outcome

•  CounterService -  Increment - Decrement - Reset

ACTUATOR – ADD METRICS

18

Page 19: Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

•  Start using Spring Boot today for you Spring Applications!

•  Reduce configuration ”noise” dramatically

•  Think about what you don’t need to write! •  Enter the microservice arena the ”easy” way

WRAP UP

19

Page 20: Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

•  Spring Boot - http://projects.spring.io/spring-boot

•  Initializr - http://start.spring.io

•  GitHub - https://github.com/spring-projects/spring-boot -  https://github.com/spring-projects/spring-boot/tree/master/spring-boot-starters

•  Callista blogs -  http://callistaenterprise.se/blogg/teknik/2014/04/15/a-first-look-at-spring-boot/ -  http://callistaenterprise.se/blogg/teknik/2015/10/09/spring-boot-app-as-a-

windows-service/

LINKS

20

Page 21: Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

21

?

Page 22: Spring Boot - Callista · Spring yyy con!g props Spring xxx con!g props SPRING BOOT EMERGING 4 Spring Boot! props Spring Security con!g props pom.xml + con!g Spring Data

•  QUIZ !! PETERS PRESENTATION

22