Professional Documents
Culture Documents
MATS EKHAMMAR
2016-01-27 | CALLISTAENTERPRISE.SE
AGENDA
• Simple example
• What is Spring Boot?
• Demo application
• Jarfiles
• Developer Tools
• Configuration from config server
• Actuator
• Wrap up
2
INTRODUCING SPRING BOOT
• Simple example
- REST service
4
WHAT IS SPRING BOOT
• Starter POMS
- Automatic configuration with sensible defaults
- Example: spring-boot-starter-web
• Features
- Monitoring
- Metrics
- …
5
WHY – WHEN
6
DEMO APPLICATION
• REST endpoint
- /roll
7
JAR FILES
• demo-0.0.1-SNAPSHOT.jar
- big
• über-jar
• MANIFEST.MF
- Main-Class: org.springframework.boot.loader.JarLauncher
8
EXECUTABLE JAR
• ”Script file”
• pom.xml
…
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
…
9
MAIN APPLICATION CLASS
@SpringBootApplication
public class DicesServiceApplication {
10
@SPRINGBOOTAPPLICATION
• @Configuration
• @ComponentScan
• @EnableAutoConfiguration
11
POM.XML
• Parent
- version 1.3.2.RELEASE
• Dependencies
- org.springframework.boot
» spring-boot-starter-web
» spring-boot-starter-thymeleaf
» spring-boot-starter-test
12
SPRING-BOOT-STARTER-WEB
• 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
13
TURN ON DEPENDENCIES
• Dependencies to turn on
- DevTools
- Config
- Actuator
14
DEVELOPER TOOLS
• Automatic restart
- Code changes require restart of application
• LiveReload
- html, javascript, templates, images, stylesheets, …
15
CONFIGURATION FROM EXTERNAL APPLICATION
dices-service config-server
• Configuration server
- Holds configurations for different applications
16
ACTUATOR
• REST Endpoints
- /beans
- /autoconfig
- /env
- /mappings
- …
- /health
- /metrics
- ...
17
ACTUATOR – ADD METRICS
• CounterService
- Increment
- Decrement
- Reset
18
WRAP UP
19
LINKS
• 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/
20
21
?
PETERS PRESENTATION
• QUIZ !!
22