SlideShare a Scribd company logo
An introduction
Jonathan Holloway,
Chief Architect, Brightpearl
Twitter: @jph98
Spring Boot
What the heck is Spring Boot
Fundamentally it’s scaffolding for building Spring based services
Awesome! Helps you get going quicker.
Similar to Dropwizard (but that came first) - http://www.dropwizard.io/
Comes with a number of out the box components
Mix and match to what you need
Why we chose it?
Wanted to build services quickly for a project
Lots of Spring experience within the development team
Looked like it integrated with other frameworks nicely (just Maven after all):
Jersey
Jackson
Spring Framework
Spring Data
Spring Boot Components
You can use starter Maven POM’s to get going quicker:
REST frameworks, Spring REST by default, but we used Jersey
N.b. Spring Boot Actuator (Metrics etc…) doesn’t play with this. Use Codahale instead.
Embedded Tomcat, we swapped this for Undertow
Standard Spring annotations
Works well with Spring Data (but isn’t part of Spring Boot)
Spring Boot Components
Various logging frameworks (we chose slf4j and logback)
Spring Boot Actuator
Security
Metrics
Our Spring Boot Stack
Spring Boot Architecture - Package Structure
We opted for the following package structure:
Application
Repositories - our persistent (MongoDB repos)
Services - service layer for interacting with our legacy API
Validation - our JSR 303 validators for business logic
Config
Mainly our classes for binding configuration from application.properties
Spring Boot Architecture - Package Structure
Infrastructure
Isolation package for our third party dependencies
Resources
Our main REST classes with Jersey annotations
Utils
Utility classes
Where’s the domain package?
Used a separate project for this (an API project specifically)
Used Swagger to specify the domain objects
Generated a Java build using a Gradle build script, why Gradle?
Munged a parent POM into the generated project
Installed into Artifactory for use in our Spring boot service
You get an Application entry point, two key annotations
Configuration by default uses an application.properties file from the resources folder.
In the following we bind these to a Java class for use in the application…
@SpringBootApplication
@EnableConfigurationProperties
public class Application {
@Autowired
@NotNull
private ServerProps serverProps;
Application (Entry Point)
Resource - An Example
@Component
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class ProductResource {
private ProductTaxResource productTaxResource;
@Autowired
public ProductResource(ProductTaxResource productTaxResource) {
this.productTaxResource = productTaxResource;
}
@Path("{productId}/tax-code")
public ProductTaxResource productTaxCodeResource() {
return productTaxResource;
}
}
Repository - An Example
public interface TaxRepository extends MongoRepository<StoreProductTaxData, Integer> {
List<StoreProductTaxData> findByProductId(int productId);
StoreProductTaxData findByStoreIdAndProductId(int storeId, int productId);
}
MongoDB Persistent Object Example
@Document(collection = ProductTaxData.COLLECTION)
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TaxData {
public static final String COLLECTION = "producttaxes";
@Id
private int productId;
private Integer taxCodeId;
private boolean taxable;
}
Some Helper Classes
Found the following very helpful:
Lombok - to reduce boilerplate Java code and generate getters, setters, constructors,
tostring, equals, hashcode and all the things we hate doing
https://projectlombok.org/
Model Mapper - for converting between legacy objects (from our old API) and our
new API objects
http://modelmapper.org/
Spring Boot Testing
Used two approaches for testing:
REST Assured - for hitting the API and doing end to end tests
https://github.com/jayway/rest-assured
Spring Integration - for doing integration testing with JUnit
Embedded MongoDB (Flapdoodle)
https://github.com/flapdoodle-oss/de.flapdoodle.embed.mongo
The Banner
Where would we be with an ASCII banner to display at startup?
Add a file into resources called banner.txt and use Maven resources/filtering to copy it
over to your binary
We used this to generate some ascii art:
http://www.patorjk.com/software/taag/
Spring boot - an introduction

More Related Content

What's hot

Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
Purbarun Chakrabarti
 
Spring boot
Spring bootSpring boot
Spring boot
sdeeg
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
Naphachara Rattanawilai
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
Trey Howard
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
Joshua Long
 
Spring Core
Spring CoreSpring Core
Spring Core
Pushan Bhattacharya
 
Spring Boot
Spring BootSpring Boot
Spring Boot
Jaran Flaath
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
Serhat Can
 
Spring boot
Spring bootSpring boot
Spring boot
Gyanendra Yadav
 
Spring annotation
Spring annotationSpring annotation
Spring annotation
Rajiv Srivastava
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOP
Dzmitry Naskou
 
Spring boot
Spring bootSpring boot
Spring boot
Pradeep Shanmugam
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
Santosh Kumar Kar
 
Introduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examplesIntroduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examples
ecosio GmbH
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
Pravin Pundge
 
Spring ppt
Spring pptSpring ppt
Spring ppt
Mumbai Academisc
 
Spring Boot
Spring BootSpring Boot
Spring Boot
koppenolski
 
Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans
Hitesh-Java
 
Spring data presentation
Spring data presentationSpring data presentation
Spring data presentation
Oleksii Usyk
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
Hùng Nguyễn Huy
 

What's hot (20)

Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
Spring boot
Spring bootSpring boot
Spring boot
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
 
Spring Core
Spring CoreSpring Core
Spring Core
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Spring boot
Spring bootSpring boot
Spring boot
 
Spring annotation
Spring annotationSpring annotation
Spring annotation
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOP
 
Spring boot
Spring bootSpring boot
Spring boot
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
 
Introduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examplesIntroduction to JPA and Hibernate including examples
Introduction to JPA and Hibernate including examples
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
Spring ppt
Spring pptSpring ppt
Spring ppt
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans
 
Spring data presentation
Spring data presentationSpring data presentation
Spring data presentation
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 

Viewers also liked

Cloud Native PWAs (progressive web apps with Spring Boot and Angular) - DevNe...
Cloud Native PWAs (progressive web apps with Spring Boot and Angular) - DevNe...Cloud Native PWAs (progressive web apps with Spring Boot and Angular) - DevNe...
Cloud Native PWAs (progressive web apps with Spring Boot and Angular) - DevNe...
Matt Raible
 
Building a PWA with Ionic, Angular and Spring Boot - Jfokus 2017
Building a PWA with Ionic, Angular and Spring Boot - Jfokus 2017Building a PWA with Ionic, Angular and Spring Boot - Jfokus 2017
Building a PWA with Ionic, Angular and Spring Boot - Jfokus 2017
Matt Raible
 
Migrating your monolithic application for micro services with JHipster
Migrating your monolithic application for micro services with JHipsterMigrating your monolithic application for micro services with JHipster
Migrating your monolithic application for micro services with JHipster
Lazaro Prates Junior
 
Angular 2
Angular 2Angular 2
Angular 2
Paulo Pires
 
JHipster
JHipsterJHipster
JHipster
Yuen-Kuei Hsueh
 
What's New in JHipsterLand - DevNexus 2017
What's New in JHipsterLand - DevNexus 2017What's New in JHipsterLand - DevNexus 2017
What's New in JHipsterLand - DevNexus 2017
Matt Raible
 
Angular 2
Angular 2Angular 2
Angular 2
Pramod Raghav
 
GDG Angular 2
GDG Angular 2GDG Angular 2
GDG Angular 2
Leonardo Marcelino
 
Introduction à Angular 2
Introduction à Angular 2Introduction à Angular 2
Introduction à Angular 2
Laurent Duveau
 
Introduction à Angular 2
Introduction à Angular 2Introduction à Angular 2
Introduction à Angular 2
Vincent Caillierez
 

Viewers also liked (10)

Cloud Native PWAs (progressive web apps with Spring Boot and Angular) - DevNe...
Cloud Native PWAs (progressive web apps with Spring Boot and Angular) - DevNe...Cloud Native PWAs (progressive web apps with Spring Boot and Angular) - DevNe...
Cloud Native PWAs (progressive web apps with Spring Boot and Angular) - DevNe...
 
Building a PWA with Ionic, Angular and Spring Boot - Jfokus 2017
Building a PWA with Ionic, Angular and Spring Boot - Jfokus 2017Building a PWA with Ionic, Angular and Spring Boot - Jfokus 2017
Building a PWA with Ionic, Angular and Spring Boot - Jfokus 2017
 
Migrating your monolithic application for micro services with JHipster
Migrating your monolithic application for micro services with JHipsterMigrating your monolithic application for micro services with JHipster
Migrating your monolithic application for micro services with JHipster
 
Angular 2
Angular 2Angular 2
Angular 2
 
JHipster
JHipsterJHipster
JHipster
 
What's New in JHipsterLand - DevNexus 2017
What's New in JHipsterLand - DevNexus 2017What's New in JHipsterLand - DevNexus 2017
What's New in JHipsterLand - DevNexus 2017
 
Angular 2
Angular 2Angular 2
Angular 2
 
GDG Angular 2
GDG Angular 2GDG Angular 2
GDG Angular 2
 
Introduction à Angular 2
Introduction à Angular 2Introduction à Angular 2
Introduction à Angular 2
 
Introduction à Angular 2
Introduction à Angular 2Introduction à Angular 2
Introduction à Angular 2
 

Similar to Spring boot - an introduction

Springboot2 postgresql-jpa-hibernate-crud-example with test
Springboot2 postgresql-jpa-hibernate-crud-example with testSpringboot2 postgresql-jpa-hibernate-crud-example with test
Springboot2 postgresql-jpa-hibernate-crud-example with test
HyukSun Kwon
 
Building a Spring Boot Application - Ask the Audience! (from JavaLand 2017)
Building a Spring Boot Application - Ask the Audience!  (from JavaLand 2017)Building a Spring Boot Application - Ask the Audience!  (from JavaLand 2017)
Building a Spring Boot Application - Ask the Audience! (from JavaLand 2017)
🎤 Hanno Embregts 🎸
 
Springboot2 postgresql-jpa-hibernate-crud-example
Springboot2 postgresql-jpa-hibernate-crud-exampleSpringboot2 postgresql-jpa-hibernate-crud-example
Springboot2 postgresql-jpa-hibernate-crud-example
HyukSun Kwon
 
Building a Spring Boot Application - Ask the Audience!
Building a Spring Boot Application - Ask the Audience!Building a Spring Boot Application - Ask the Audience!
Building a Spring Boot Application - Ask the Audience!
🎤 Hanno Embregts 🎸
 
Declaring Server App Components in Pure Java
Declaring Server App Components in Pure JavaDeclaring Server App Components in Pure Java
Declaring Server App Components in Pure Java
Atlassian
 
Spring Boot
Spring BootSpring Boot
Spring Boot
Jaydeep Kale
 
Spring boot
Spring bootSpring boot
SpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptxSpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptx
SUFYAN SATTAR
 
Spring boot jpa
Spring boot jpaSpring boot jpa
Spring boot jpa
Hamid Ghorbani
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC framework
Mohit Gupta
 
Spring Boot Whirlwind Tour
Spring Boot Whirlwind TourSpring Boot Whirlwind Tour
Spring Boot Whirlwind Tour
VMware Tanzu
 
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdf
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdfdokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdf
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdf
Appster1
 
dokumen.tips_rediscovering-spring-with-spring-boot1.pdf
dokumen.tips_rediscovering-spring-with-spring-boot1.pdfdokumen.tips_rediscovering-spring-with-spring-boot1.pdf
dokumen.tips_rediscovering-spring-with-spring-boot1.pdf
Appster1
 
Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)
Gunith Devasurendra
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
Lars Vogel
 
Spring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applicationsSpring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applications
michaelaaron25322
 
Apache Aries Blog Sample
Apache Aries Blog SampleApache Aries Blog Sample
Apache Aries Blog Sample
Skills Matter
 
Building a Spring Boot Application - Ask the Audience! (from JVMCon 2018)
Building a Spring Boot Application - Ask the Audience! (from JVMCon 2018)Building a Spring Boot Application - Ask the Audience! (from JVMCon 2018)
Building a Spring Boot Application - Ask the Audience! (from JVMCon 2018)
🎤 Hanno Embregts 🎸
 
Introduction to Spring Boot.pdf
Introduction to Spring Boot.pdfIntroduction to Spring Boot.pdf
Introduction to Spring Boot.pdf
ShaiAlmog1
 
Module 6 _ Spring Boot for java application to begin
Module 6 _ Spring Boot for java application to beginModule 6 _ Spring Boot for java application to begin
Module 6 _ Spring Boot for java application to begin
Deepakprasad838637
 

Similar to Spring boot - an introduction (20)

Springboot2 postgresql-jpa-hibernate-crud-example with test
Springboot2 postgresql-jpa-hibernate-crud-example with testSpringboot2 postgresql-jpa-hibernate-crud-example with test
Springboot2 postgresql-jpa-hibernate-crud-example with test
 
Building a Spring Boot Application - Ask the Audience! (from JavaLand 2017)
Building a Spring Boot Application - Ask the Audience!  (from JavaLand 2017)Building a Spring Boot Application - Ask the Audience!  (from JavaLand 2017)
Building a Spring Boot Application - Ask the Audience! (from JavaLand 2017)
 
Springboot2 postgresql-jpa-hibernate-crud-example
Springboot2 postgresql-jpa-hibernate-crud-exampleSpringboot2 postgresql-jpa-hibernate-crud-example
Springboot2 postgresql-jpa-hibernate-crud-example
 
Building a Spring Boot Application - Ask the Audience!
Building a Spring Boot Application - Ask the Audience!Building a Spring Boot Application - Ask the Audience!
Building a Spring Boot Application - Ask the Audience!
 
Declaring Server App Components in Pure Java
Declaring Server App Components in Pure JavaDeclaring Server App Components in Pure Java
Declaring Server App Components in Pure Java
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring boot
Spring bootSpring boot
Spring boot
 
SpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptxSpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptx
 
Spring boot jpa
Spring boot jpaSpring boot jpa
Spring boot jpa
 
Spring MVC framework
Spring MVC frameworkSpring MVC framework
Spring MVC framework
 
Spring Boot Whirlwind Tour
Spring Boot Whirlwind TourSpring Boot Whirlwind Tour
Spring Boot Whirlwind Tour
 
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdf
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdfdokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdf
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdf
 
dokumen.tips_rediscovering-spring-with-spring-boot1.pdf
dokumen.tips_rediscovering-spring-with-spring-boot1.pdfdokumen.tips_rediscovering-spring-with-spring-boot1.pdf
dokumen.tips_rediscovering-spring-with-spring-boot1.pdf
 
Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
 
Spring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applicationsSpring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applications
 
Apache Aries Blog Sample
Apache Aries Blog SampleApache Aries Blog Sample
Apache Aries Blog Sample
 
Building a Spring Boot Application - Ask the Audience! (from JVMCon 2018)
Building a Spring Boot Application - Ask the Audience! (from JVMCon 2018)Building a Spring Boot Application - Ask the Audience! (from JVMCon 2018)
Building a Spring Boot Application - Ask the Audience! (from JVMCon 2018)
 
Introduction to Spring Boot.pdf
Introduction to Spring Boot.pdfIntroduction to Spring Boot.pdf
Introduction to Spring Boot.pdf
 
Module 6 _ Spring Boot for java application to begin
Module 6 _ Spring Boot for java application to beginModule 6 _ Spring Boot for java application to begin
Module 6 _ Spring Boot for java application to begin
 

More from Jonathan Holloway

The Role of the Architect
The Role of the ArchitectThe Role of the Architect
The Role of the Architect
Jonathan Holloway
 
Jenkins CI presentation
Jenkins CI presentationJenkins CI presentation
Jenkins CI presentation
Jonathan Holloway
 
Mockito intro
Mockito introMockito intro
Mockito intro
Jonathan Holloway
 
Debugging
DebuggingDebugging
SOLID principles
SOLID principlesSOLID principles
SOLID principles
Jonathan Holloway
 
Application design for the cloud using AWS
Application design for the cloud using AWSApplication design for the cloud using AWS
Application design for the cloud using AWS
Jonathan Holloway
 
Building data pipelines
Building data pipelinesBuilding data pipelines
Building data pipelines
Jonathan Holloway
 
Introduction to JVM languages and Fantom (very brief)
Introduction to JVM languages and Fantom (very brief)Introduction to JVM languages and Fantom (very brief)
Introduction to JVM languages and Fantom (very brief)
Jonathan Holloway
 
Database migration with flyway
Database migration  with flywayDatabase migration  with flyway
Database migration with flyway
Jonathan Holloway
 
Lightweight web frameworks
Lightweight web frameworksLightweight web frameworks
Lightweight web frameworks
Jonathan Holloway
 
Introduction to using MongoDB with Ruby
Introduction to using MongoDB with RubyIntroduction to using MongoDB with Ruby
Introduction to using MongoDB with Ruby
Jonathan Holloway
 

More from Jonathan Holloway (11)

The Role of the Architect
The Role of the ArchitectThe Role of the Architect
The Role of the Architect
 
Jenkins CI presentation
Jenkins CI presentationJenkins CI presentation
Jenkins CI presentation
 
Mockito intro
Mockito introMockito intro
Mockito intro
 
Debugging
DebuggingDebugging
Debugging
 
SOLID principles
SOLID principlesSOLID principles
SOLID principles
 
Application design for the cloud using AWS
Application design for the cloud using AWSApplication design for the cloud using AWS
Application design for the cloud using AWS
 
Building data pipelines
Building data pipelinesBuilding data pipelines
Building data pipelines
 
Introduction to JVM languages and Fantom (very brief)
Introduction to JVM languages and Fantom (very brief)Introduction to JVM languages and Fantom (very brief)
Introduction to JVM languages and Fantom (very brief)
 
Database migration with flyway
Database migration  with flywayDatabase migration  with flyway
Database migration with flyway
 
Lightweight web frameworks
Lightweight web frameworksLightweight web frameworks
Lightweight web frameworks
 
Introduction to using MongoDB with Ruby
Introduction to using MongoDB with RubyIntroduction to using MongoDB with Ruby
Introduction to using MongoDB with Ruby
 

Recently uploaded

(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
Priyanka Aash
 
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyyActive Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
RaminGhanbari2
 
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptxRPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
SynapseIndia
 
How to build a generative AI solution A step-by-step guide (2).pdf
How to build a generative AI solution A step-by-step guide (2).pdfHow to build a generative AI solution A step-by-step guide (2).pdf
How to build a generative AI solution A step-by-step guide (2).pdf
ChristopherTHyatt
 
WhatsApp Spy Online Trackers and Monitoring Apps
WhatsApp Spy Online Trackers and Monitoring AppsWhatsApp Spy Online Trackers and Monitoring Apps
WhatsApp Spy Online Trackers and Monitoring Apps
HackersList
 
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes..."Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
Anant Gupta
 
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdfBT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
Neo4j
 
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptxDublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
Kunal Gupta
 
Evolution of iPaaS - simplify IT workloads to provide a unified view of data...
Evolution of iPaaS - simplify IT workloads to provide a unified view of  data...Evolution of iPaaS - simplify IT workloads to provide a unified view of  data...
Evolution of iPaaS - simplify IT workloads to provide a unified view of data...
Torry Harris
 
Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024
aakash malhotra
 
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
sunilverma7884
 
Salesforce AI & Einstein Copilot Workshop
Salesforce AI & Einstein Copilot WorkshopSalesforce AI & Einstein Copilot Workshop
Salesforce AI & Einstein Copilot Workshop
CEPTES Software Inc
 
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
alexjohnson7307
 
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
Kief Morris
 
EuroPython 2024 - Streamlining Testing in a Large Python Codebase
EuroPython 2024 - Streamlining Testing in a Large Python CodebaseEuroPython 2024 - Streamlining Testing in a Large Python Codebase
EuroPython 2024 - Streamlining Testing in a Large Python Codebase
Jimmy Lai
 
IPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite SolutionIPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite Solution
IPLOOK Networks
 
How RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptxHow RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptx
SynapseIndia
 
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptxUse Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
SynapseIndia
 
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
bhumivarma35300
 
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
aslasdfmkhan4750
 

Recently uploaded (20)

(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
(CISOPlatform Summit & SACON 2024) Keynote _ Power Digital Identities With AI...
 
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyyActive Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
Active Inference is a veryyyyyyyyyyyyyyyyyyyyyyyy
 
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptxRPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
RPA In Healthcare Benefits, Use Case, Trend And Challenges 2024.pptx
 
How to build a generative AI solution A step-by-step guide (2).pdf
How to build a generative AI solution A step-by-step guide (2).pdfHow to build a generative AI solution A step-by-step guide (2).pdf
How to build a generative AI solution A step-by-step guide (2).pdf
 
WhatsApp Spy Online Trackers and Monitoring Apps
WhatsApp Spy Online Trackers and Monitoring AppsWhatsApp Spy Online Trackers and Monitoring Apps
WhatsApp Spy Online Trackers and Monitoring Apps
 
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes..."Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
"Mastering Graphic Design: Essential Tips and Tricks for Beginners and Profes...
 
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdfBT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
BT & Neo4j: Knowledge Graphs for Critical Enterprise Systems.pptx.pdf
 
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptxDublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
Dublin_mulesoft_meetup_Mulesoft_Salesforce_Integration (1).pptx
 
Evolution of iPaaS - simplify IT workloads to provide a unified view of data...
Evolution of iPaaS - simplify IT workloads to provide a unified view of  data...Evolution of iPaaS - simplify IT workloads to provide a unified view of  data...
Evolution of iPaaS - simplify IT workloads to provide a unified view of data...
 
Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024Three New Criminal Laws in India 1 July 2024
Three New Criminal Laws in India 1 July 2024
 
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
Girls call Kolkata 👀 XXXXXXXXXXX 👀 Rs.9.5 K Cash Payment With Room Delivery
 
Salesforce AI & Einstein Copilot Workshop
Salesforce AI & Einstein Copilot WorkshopSalesforce AI & Einstein Copilot Workshop
Salesforce AI & Einstein Copilot Workshop
 
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
leewayhertz.com-AI agents for healthcare Applications benefits and implementa...
 
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
[Talk] Moving Beyond Spaghetti Infrastructure [AOTB] 2024-07-04.pdf
 
EuroPython 2024 - Streamlining Testing in a Large Python Codebase
EuroPython 2024 - Streamlining Testing in a Large Python CodebaseEuroPython 2024 - Streamlining Testing in a Large Python Codebase
EuroPython 2024 - Streamlining Testing in a Large Python Codebase
 
IPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite SolutionIPLOOK Remote-Sensing Satellite Solution
IPLOOK Remote-Sensing Satellite Solution
 
How RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptxHow RPA Help in the Transportation and Logistics Industry.pptx
How RPA Help in the Transportation and Logistics Industry.pptx
 
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptxUse Cases & Benefits of RPA in Manufacturing in 2024.pptx
Use Cases & Benefits of RPA in Manufacturing in 2024.pptx
 
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
High Profile Girls call Service Pune 000XX00000 Provide Best And Top Girl Ser...
 
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
High Profile Girls Call ServiCe Hyderabad 0000000000 Tanisha Best High Class ...
 

Spring boot - an introduction

  • 1. An introduction Jonathan Holloway, Chief Architect, Brightpearl Twitter: @jph98 Spring Boot
  • 2. What the heck is Spring Boot Fundamentally it’s scaffolding for building Spring based services Awesome! Helps you get going quicker. Similar to Dropwizard (but that came first) - http://www.dropwizard.io/ Comes with a number of out the box components Mix and match to what you need
  • 3. Why we chose it? Wanted to build services quickly for a project Lots of Spring experience within the development team Looked like it integrated with other frameworks nicely (just Maven after all): Jersey Jackson Spring Framework Spring Data
  • 4. Spring Boot Components You can use starter Maven POM’s to get going quicker: REST frameworks, Spring REST by default, but we used Jersey N.b. Spring Boot Actuator (Metrics etc…) doesn’t play with this. Use Codahale instead. Embedded Tomcat, we swapped this for Undertow Standard Spring annotations Works well with Spring Data (but isn’t part of Spring Boot)
  • 5. Spring Boot Components Various logging frameworks (we chose slf4j and logback) Spring Boot Actuator Security Metrics
  • 7. Spring Boot Architecture - Package Structure We opted for the following package structure: Application Repositories - our persistent (MongoDB repos) Services - service layer for interacting with our legacy API Validation - our JSR 303 validators for business logic Config Mainly our classes for binding configuration from application.properties
  • 8. Spring Boot Architecture - Package Structure Infrastructure Isolation package for our third party dependencies Resources Our main REST classes with Jersey annotations Utils Utility classes
  • 9. Where’s the domain package? Used a separate project for this (an API project specifically) Used Swagger to specify the domain objects Generated a Java build using a Gradle build script, why Gradle? Munged a parent POM into the generated project Installed into Artifactory for use in our Spring boot service
  • 10. You get an Application entry point, two key annotations Configuration by default uses an application.properties file from the resources folder. In the following we bind these to a Java class for use in the application… @SpringBootApplication @EnableConfigurationProperties public class Application { @Autowired @NotNull private ServerProps serverProps; Application (Entry Point)
  • 11. Resource - An Example @Component @Produces(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON) public class ProductResource { private ProductTaxResource productTaxResource; @Autowired public ProductResource(ProductTaxResource productTaxResource) { this.productTaxResource = productTaxResource; } @Path("{productId}/tax-code") public ProductTaxResource productTaxCodeResource() { return productTaxResource; } }
  • 12. Repository - An Example public interface TaxRepository extends MongoRepository<StoreProductTaxData, Integer> { List<StoreProductTaxData> findByProductId(int productId); StoreProductTaxData findByStoreIdAndProductId(int storeId, int productId); }
  • 13. MongoDB Persistent Object Example @Document(collection = ProductTaxData.COLLECTION) @Data @NoArgsConstructor @AllArgsConstructor public class TaxData { public static final String COLLECTION = "producttaxes"; @Id private int productId; private Integer taxCodeId; private boolean taxable; }
  • 14. Some Helper Classes Found the following very helpful: Lombok - to reduce boilerplate Java code and generate getters, setters, constructors, tostring, equals, hashcode and all the things we hate doing https://projectlombok.org/ Model Mapper - for converting between legacy objects (from our old API) and our new API objects http://modelmapper.org/
  • 15. Spring Boot Testing Used two approaches for testing: REST Assured - for hitting the API and doing end to end tests https://github.com/jayway/rest-assured Spring Integration - for doing integration testing with JUnit Embedded MongoDB (Flapdoodle) https://github.com/flapdoodle-oss/de.flapdoodle.embed.mongo
  • 16. The Banner Where would we be with an ASCII banner to display at startup? Add a file into resources called banner.txt and use Maven resources/filtering to copy it over to your binary We used this to generate some ascii art: http://www.patorjk.com/software/taag/