SlideShare a Scribd company logo
SPRING BOOT & 
MICROSERVICES 
@ladislavGazo 
gazo@seges.sk
Spring Boot and Microservices
huge application servers 
monolithic architecture 
long restarts 
no save-reload cycle 
wired to a set of dependencies
Spring Boot and Microservices
Spring Boot and Microservices
Spring Boot and Microservices
MICROSERVICES
PROS 
Each microservice is relatively small 
Easier for a developer to understand 
The IDE is faster making developers more productive 
The web container starts faster 
Easier to scale development. 
Each team can develop, deploy and scale their service 
independently of all of the other teams.
PROS 2 
Improved fault isolation 
In comparison, one misbehaving component of a monolithic 
architecture can bring down the entire system. 
Each service can be developed and deployed independently 
Eliminates any long-term commitment to a technology stack
BUT... 
(there is always at least one...) 
Developers must deal with the additional complexity of 
creating a distributed system 
testing 
transactions 
use-cases span multiple microservices 
Deployment complexity In production 
Increased memory consumption
... TACKLE WITH 
when to split to multiple microservices 
what should be inside one microservice 
single responsibility principle 
... 
it is the art
SPRING BOOT 
http://projects.spring.io/spring-boot/ 
opinionated way how to do modern applications
VERY EASY TO START 
<parent> 
<groupid>org.springframework.boot</groupid> 
<artifactid>spring-boot-starter-parent</artifactid> 
<version>1.1.8.RELEASE</version> 
</parent> 
<dependencies> 
<dependency> 
<groupid>org.springframework.boot</groupid> 
<artifactid>spring-boot-starter-web</artifactid> 
</dependency> 
</dependencies> 
ta-daaaa .... web app built :)
APP CODE 
package hello; 
import org.springframework.boot.*; 
import org.springframework.boot.autoconfigure.*; 
import org.springframework.stereotype.*; 
import org.springframework.web.bind.annotation.*; 
@Controller 
@EnableAutoConfiguration 
public class SampleController { 
@RequestMapping("/") 
@ResponseBody 
String home() { 
return "Hello World!"; 
} 
public static void main(String[] args) throws Exception { 
SpringApplication.run(SampleController.class, args); 
... the beauty of autoconfiguration
Spring Boot and Microservices
3 OPTIONS 
JRebel 
jHipster Reloader 
Spring Loaded
JHIPSTER RELOADER 
-javaagent:/home/user/.m2/repository/io/github/jhipster/loaded/agent/0.12/agent-0.12.jar 
<profiles> 
<profile> 
<id>reloaded</id> 
<dependencies> 
<dependency> 
<groupId>io.github.jhipster.loaded</groupId> 
<artifactId>agent</artifactId> 
<version>0.12</version> 
<exclusions> 
<exclusion> 
<groupId>org.springframework</groupId> 
<artifactId>springloaded</artifactId> 
</exclusion> 
</exclusions> 
</dependency> 
<dependency> 
<groupId>org.springframework</groupId> 
<artifactId>springloaded</artifactId> 
</dependency> 
</dependencies> 
</profile> 
</profiles>
INTERESTING DEPENDENCIES 
benefit of Spring Boot 
MVC 
data access 
templating 
security 
... 
... anything from the Spring stack
REST 
@RestController 
based on Spring MVC
TEMPLATING 
<dependency> 
<groupId>org.springframework.boot</groupId> 
<artifactId>spring-boot-starter-thymeleaf</artifactId> 
</dependency> 
using Thymeleaf
SPRING SECURITY 
<dependency> 
<groupId>org.springframework.boot</groupId> 
<artifactId>spring-boot-starter-security</artifactId> 
</dependency> 
@EnableWebMvcSecurity 
@EnableGlobalMethodSecurity 
http.authorizeRequests().antMatchers("/identity/login", "/page/**", "/client/**", "/user/**" 
http.csrf().disable(); 
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); 
http.addFilterBefore(new AuthenticationTokenFilter(identityService), AnonymousAuthenticationFilter 
http.exceptionHandling().authenticationEntryPoint(new UnauthorizedEntryPoint());
MIGRATIONS 
<dependency> 
<groupId>org.flywaydb</groupId> 
<artifactId>flyway-core</artifactId> 
</dependency> 
migration files 
V1.1__init.sql 
V1.2__data.sql 
...
DATA ACCESS 
<dependency> 
<groupId>com.h2database</groupId> 
<artifactId>h2</artifactId> 
</dependency> 
<dependency> 
<groupId>org.postgresql</groupId> 
<artifactId>postgresql</artifactId> 
</dependency> 
autodetection of the driver
DATA ACCESS II. 
spring.datasource.url: jdbc:postgresql://localhost/mydb 
spring.datasource.username: myuser 
spring.datasource.password: mypass 
spring.datasource.driverClassName: org.postgresql.Driver 
<dependency> 
<groupId>org.springframework.boot</groupId> 
<artifactId>spring-boot-starter-jdbc</artifactId> 
</dependency>
CONFIGURATION 
driven mainly by: 
Spring Java Configuration 
Spring Annotations 
Spring Profiles 
simple YAML / properties file
CHERRY 
@Component 
@ConfigurationProperties(prefix="connection") 
public class ConnectionSettings { 
private String username; 
private InetAddress remoteAddress; 
// ... getters and setters 
} 
# application.yml 
connection: 
username: admin 
remoteAddress: 192.168.1.1
KONTANJERE
SKALA
GITER8 TEMPLATE 
https://github.com/lgazo/scala-boot.g8 
curl https://raw.githubusercontent.com/n8han/conscript/master/setup.sh | sh 
# add to your path ~/bin 
cs n8han/giter8 
g8 lgazo/scala-boot
QUESTIONS? 
@ladislavGazo 
gazo@seges.sk
THANK YOU... FOR... 
ATTENTION

More Related Content

PDF
Spring boot introduction
PPTX
Introduction to spring boot
PDF
Introduction to Spring Boot!
PPT
Spring Core
PDF
Spring Boot
PPTX
Spring Boot Tutorial
PPTX
Spring boot Introduction
PDF
Spring Framework - Core
Spring boot introduction
Introduction to spring boot
Introduction to Spring Boot!
Spring Core
Spring Boot
Spring Boot Tutorial
Spring boot Introduction
Spring Framework - Core

What's hot (20)

PPTX
Spring Boot
PPTX
Java Spring Framework
PDF
Understanding MicroSERVICE Architecture with Java & Spring Boot
PPTX
Spring boot
PPTX
Spring boot
PPTX
Spring boot
PPTX
Spring Boot and REST API
PDF
Spring Boot
PDF
Spring framework aop
PPTX
Spring data jpa
PDF
Spring Boot Interview Questions | Edureka
PPT
Spring Framework
PDF
Microservices with Java, Spring Boot and Spring Cloud
PPTX
Introduction to Spring Boot
ODP
Xke spring boot
PDF
Java 8 Stream API. A different way to process collections.
PDF
Spring boot
PDF
Spring Boot
PDF
PUC SE Day 2019 - SpringBoot
PDF
Java 8 Lambda Expressions
Spring Boot
Java Spring Framework
Understanding MicroSERVICE Architecture with Java & Spring Boot
Spring boot
Spring boot
Spring boot
Spring Boot and REST API
Spring Boot
Spring framework aop
Spring data jpa
Spring Boot Interview Questions | Edureka
Spring Framework
Microservices with Java, Spring Boot and Spring Cloud
Introduction to Spring Boot
Xke spring boot
Java 8 Stream API. A different way to process collections.
Spring boot
Spring Boot
PUC SE Day 2019 - SpringBoot
Java 8 Lambda Expressions
Ad

Similar to Spring Boot and Microservices (20)

PDF
"Micro-frontends: Scalable and Modular Frontend in Parimatch Tech", Kyrylo Ai...
PPTX
Struts 1
PDF
micro-frontends-with-vuejs
PDF
Developing large scale JavaScript applications
PDF
Meetup Performance
PDF
Meetup Performance
PDF
Javaone - Gradle: Harder, Better, Stronger, Faster
PDF
[Ultracode Munich #4] Short introduction to the new Android build system incl...
PPTX
struts unit best pdf for struts java.pptx
PPTX
struts unit best pdf for struts java.pptx
PPTX
Plone FSR
PPTX
SeedStack feature tour
PPT
JavaScript Modules in Practice
PPTX
Writing a massive javascript app
PDF
From Zero to Cloud in 12 Easy Factors
PPTX
React django
PDF
Using Renderless Components in Vue.js during your software development.
PDF
Struts2 tutorial
PDF
Struts2 tutorial
PPTX
Riga Dev Day - Automated Android Continuous Integration
"Micro-frontends: Scalable and Modular Frontend in Parimatch Tech", Kyrylo Ai...
Struts 1
micro-frontends-with-vuejs
Developing large scale JavaScript applications
Meetup Performance
Meetup Performance
Javaone - Gradle: Harder, Better, Stronger, Faster
[Ultracode Munich #4] Short introduction to the new Android build system incl...
struts unit best pdf for struts java.pptx
struts unit best pdf for struts java.pptx
Plone FSR
SeedStack feature tour
JavaScript Modules in Practice
Writing a massive javascript app
From Zero to Cloud in 12 Easy Factors
React django
Using Renderless Components in Vue.js during your software development.
Struts2 tutorial
Struts2 tutorial
Riga Dev Day - Automated Android Continuous Integration
Ad

More from seges (8)

PDF
Automated Tomcat Management
PDF
Javist Being Cheftain
PDF
Multi-tenancy in Java
PDF
OSGi experiments
PDF
Internetová prítomnosť a content management
PDF
AngularJS first steps
PDF
GWT Workshop
PDF
Ako sme zistili ze asi robime Scrum
Automated Tomcat Management
Javist Being Cheftain
Multi-tenancy in Java
OSGi experiments
Internetová prítomnosť a content management
AngularJS first steps
GWT Workshop
Ako sme zistili ze asi robime Scrum

Recently uploaded (20)

PPTX
MYSQL Presentation for SQL database connectivity
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PDF
Empathic Computing: Creating Shared Understanding
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Modernizing your data center with Dell and AMD
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Cloud computing and distributed systems.
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Sensors and Actuators in IoT Systems using pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Advanced IT Governance
MYSQL Presentation for SQL database connectivity
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
Empathic Computing: Creating Shared Understanding
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Modernizing your data center with Dell and AMD
Spectral efficient network and resource selection model in 5G networks
Big Data Technologies - Introduction.pptx
Cloud computing and distributed systems.
Reach Out and Touch Someone: Haptics and Empathic Computing
Sensors and Actuators in IoT Systems using pdf
Understanding_Digital_Forensics_Presentation.pptx
Advanced Soft Computing BINUS July 2025.pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
GamePlan Trading System Review: Professional Trader's Honest Take
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
Network Security Unit 5.pdf for BCA BBA.
Diabetes mellitus diagnosis method based random forest with bat algorithm
Chapter 3 Spatial Domain Image Processing.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Advanced IT Governance

Spring Boot and Microservices

  • 1. SPRING BOOT & MICROSERVICES @ladislavGazo [email protected]
  • 3. huge application servers monolithic architecture long restarts no save-reload cycle wired to a set of dependencies
  • 8. PROS Each microservice is relatively small Easier for a developer to understand The IDE is faster making developers more productive The web container starts faster Easier to scale development. Each team can develop, deploy and scale their service independently of all of the other teams.
  • 9. PROS 2 Improved fault isolation In comparison, one misbehaving component of a monolithic architecture can bring down the entire system. Each service can be developed and deployed independently Eliminates any long-term commitment to a technology stack
  • 10. BUT... (there is always at least one...) Developers must deal with the additional complexity of creating a distributed system testing transactions use-cases span multiple microservices Deployment complexity In production Increased memory consumption
  • 11. ... TACKLE WITH when to split to multiple microservices what should be inside one microservice single responsibility principle ... it is the art
  • 12. SPRING BOOT http://projects.spring.io/spring-boot/ opinionated way how to do modern applications
  • 13. VERY EASY TO START <parent> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-parent</artifactid> <version>1.1.8.RELEASE</version> </parent> <dependencies> <dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-web</artifactid> </dependency> </dependencies> ta-daaaa .... web app built :)
  • 14. APP CODE package hello; import org.springframework.boot.*; import org.springframework.boot.autoconfigure.*; import org.springframework.stereotype.*; import org.springframework.web.bind.annotation.*; @Controller @EnableAutoConfiguration public class SampleController { @RequestMapping("/") @ResponseBody String home() { return "Hello World!"; } public static void main(String[] args) throws Exception { SpringApplication.run(SampleController.class, args); ... the beauty of autoconfiguration
  • 16. 3 OPTIONS JRebel jHipster Reloader Spring Loaded
  • 17. JHIPSTER RELOADER -javaagent:/home/user/.m2/repository/io/github/jhipster/loaded/agent/0.12/agent-0.12.jar <profiles> <profile> <id>reloaded</id> <dependencies> <dependency> <groupId>io.github.jhipster.loaded</groupId> <artifactId>agent</artifactId> <version>0.12</version> <exclusions> <exclusion> <groupId>org.springframework</groupId> <artifactId>springloaded</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>springloaded</artifactId> </dependency> </dependencies> </profile> </profiles>
  • 18. INTERESTING DEPENDENCIES benefit of Spring Boot MVC data access templating security ... ... anything from the Spring stack
  • 19. REST @RestController based on Spring MVC
  • 20. TEMPLATING <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> using Thymeleaf
  • 21. SPRING SECURITY <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> @EnableWebMvcSecurity @EnableGlobalMethodSecurity http.authorizeRequests().antMatchers("/identity/login", "/page/**", "/client/**", "/user/**" http.csrf().disable(); http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); http.addFilterBefore(new AuthenticationTokenFilter(identityService), AnonymousAuthenticationFilter http.exceptionHandling().authenticationEntryPoint(new UnauthorizedEntryPoint());
  • 22. MIGRATIONS <dependency> <groupId>org.flywaydb</groupId> <artifactId>flyway-core</artifactId> </dependency> migration files V1.1__init.sql V1.2__data.sql ...
  • 23. DATA ACCESS <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> </dependency> <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> </dependency> autodetection of the driver
  • 24. DATA ACCESS II. spring.datasource.url: jdbc:postgresql://localhost/mydb spring.datasource.username: myuser spring.datasource.password: mypass spring.datasource.driverClassName: org.postgresql.Driver <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency>
  • 25. CONFIGURATION driven mainly by: Spring Java Configuration Spring Annotations Spring Profiles simple YAML / properties file
  • 26. CHERRY @Component @ConfigurationProperties(prefix="connection") public class ConnectionSettings { private String username; private InetAddress remoteAddress; // ... getters and setters } # application.yml connection: username: admin remoteAddress: 192.168.1.1
  • 28. SKALA
  • 29. GITER8 TEMPLATE https://github.com/lgazo/scala-boot.g8 curl https://raw.githubusercontent.com/n8han/conscript/master/setup.sh | sh # add to your path ~/bin cs n8han/giter8 g8 lgazo/scala-boot
  • 31. THANK YOU... FOR... ATTENTION