SlideShare a Scribd company logo
1 of 19
Spring Boot
Building a REST Service in minutes
omri.spector@develeap.com
I am…
• Omri Spector, CEO deveLeap
• deveLeap mission
– Helping development teams use the right tools,
technologies & architecture to achieve their business
objective.
– Specialize in Java, CI and the JVM eco-system
• Omri
– Active commercial developer since 1985
– In Java since 2004
– Managed large multi national development groups
omri.spector@develeap.com
Agenda
• What is Spring Boot
• Creating a SpringBoot Application
• Creating a basic REST Service (POST, GET)
• Connecting to a Database
• Going forward
omri.spector@develeap.com
What is Spring boot
• Spring
• Opinionated
• Geared for fast development of robust micro
services
• Others in this arena
– Drop wizard
– Play
– Vert.x
– Jodd
– …
omri.spector@develeap.com
Where would I use SpringBoot?
• Green Field – Get new project up & running in
no time without compromising architecture
and infrastructure
• Modernizing Legacy – Gradually modernize
legacy monolith applications by moving
aspects to Spring Boot “micro-services”
Let’s code
omri.spector@develeap.com
Starting a project
• https://start.spring.io/
– Actuator: “Production Ready”
– Web: Web related functionality (e.g. MVC)
– Devtools: Hot swap during development
– Lombok: “Less boilerplate”
Later we can easily add more, e.g. “data”, “cloud”,…
omri.spector@develeap.com
Alternative start - JHipster
• JHipster is a code generation tool that
offers a much more comprehensive
starting point
• It adds opinioned use of the client side
stack:
Angular, Gulp, SASS, Bower, etc.
• It adds many common features and UI out of the
box
• The amount of code it creates is large – which can
be viewed as good or bad
omri.spector@develeap.com
What we created
• Pom – spring boot pom
• DemoApplication –
– @SpringBootApplication: spring mvc, scanner
– Main: embedded tomcat
• Resources/static, resources/template
• Application.properties (empty)
• DemoApplicationTests – context loads, Spring
test
omri.spector@develeap.com
Build & Run
• Fat Jar for easy deploy
• Actuator endpoints:
– /health,
– /env,
– /metrics,
– :
• Hot swap
omri.spector@develeap.com
Chapter 1 – POST, GET
• Domain: Simplify with lombok
• Services: @Service pojo for all business logic
• Controller: @Controller utilizing:
– @RequestMapping (hierarchical)
– @ResponseBody – to avoid writing views
– @RequestBody & @PathVariable on params
• PostMan – Post, Get, Get non existing
omri.spector@develeap.com
Chapter 2 – HTTP Errors
• Return 404 using RuntimeException with
@ResponseStatus
omri.spector@develeap.com
Chapter 3 – Working with a DB
• Add spring-boot-starter-data-jpa and a db driver
• Add a CrudRepository based @Repository
• Model object is now and @Entity with an @id
– Make sure name matches table name!
• Changed service to use it
• Configuring the db connection in application
properties
omri.spector@develeap.com
Chapter 4 – Getting a list
• Many options, from findAll to HQL to SQL
• We will use Spring Data Proxy
• Of course this is naïve, and is often improved:
– Limiting the fields returned or even defining a “light”
version
– Adding sort and paging
Iterable<Artist> findByNameContaining(String s);
omri.spector@develeap.com
Chapter 5 – It doesn’t stop here
• Spring is a very comprehensive project
• Spring-Boot wraps many of it’s aspects and
integrates many other successful open source
facilities
omri.spector@develeap.com
Typical additions
• Spring Security
• Spring Social – Facebook, Twitter, LinkedIn…
• Spring Cloud – Service discovery, Circuit breakers,
control bus, …
• Schema Management – Liquibase, Flyway
• Front end assets management – Web jars
• Transaction Management
• Spring Data – Both Relational and many NoSQL
And the list goes on…
omri.spector@develeap.com
In Summary
• Spring boot creates an:
– easy to deploy
– executable
– “fat” jar
• Management services out of the box
• In several minutes and very little code we get:
– REST against a db backend
– JPA based ORM
– And the spring power to easily add so much more
omri.spector@develeap.com
Shameless Plug
Are you considering the move to
“micro-services”?
Don’t hesitate to call:
omri.spector@develeap.com
Thank you!
www.develeap.com
Slide Share:
http://www.slideshare.net/omrispector/building-a-rest-service-in-minutes-with-spring-boot

More Related Content

What's hot (20)

Spring boot
Spring bootSpring boot
Spring boot
 
Introduction to NodeJS
Introduction to NodeJSIntroduction to NodeJS
Introduction to NodeJS
 
ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web API
 
Rest API
Rest APIRest API
Rest API
 
Web api
Web apiWeb api
Web api
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Hibernate ppt
Hibernate pptHibernate ppt
Hibernate ppt
 
React JS
React JSReact JS
React JS
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOP
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developers
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
An Introduction To REST API
An Introduction To REST APIAn Introduction To REST API
An Introduction To REST API
 
REST API
REST APIREST API
REST API
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Introduction to spring boot
Introduction to spring bootIntroduction to spring boot
Introduction to spring boot
 
REST API Design & Development
REST API Design & DevelopmentREST API Design & Development
REST API Design & Development
 
Spring boot jpa
Spring boot jpaSpring boot jpa
Spring boot jpa
 
ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
 

Viewers also liked

JHipster, modern web application development made easy
JHipster, modern web application development made easyJHipster, modern web application development made easy
JHipster, modern web application development made easyRaphaël Brugier
 
REST with Spring Boot #jqfk
REST with Spring Boot #jqfkREST with Spring Boot #jqfk
REST with Spring Boot #jqfkToshiaki Maki
 
Gestao 2.0 para Fundação Dom Cabral
Gestao 2.0 para Fundação Dom CabralGestao 2.0 para Fundação Dom Cabral
Gestao 2.0 para Fundação Dom CabralJose Claudio Terra
 
Grails 3.0先取り!? Spring Boot入門ハンズオン #jggug_boot
Grails 3.0先取り!? Spring Boot入門ハンズオン #jggug_bootGrails 3.0先取り!? Spring Boot入門ハンズオン #jggug_boot
Grails 3.0先取り!? Spring Boot入門ハンズオン #jggug_bootToshiaki Maki
 
Building REST APIs with Spring Boot and Spring Cloud
Building REST APIs with Spring Boot and Spring CloudBuilding REST APIs with Spring Boot and Spring Cloud
Building REST APIs with Spring Boot and Spring CloudKenny Bastani
 
Microservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudMicroservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudEberhard Wolff
 
Microservice With Spring Boot and Spring Cloud
Microservice With Spring Boot and Spring CloudMicroservice With Spring Boot and Spring Cloud
Microservice With Spring Boot and Spring CloudEberhard Wolff
 

Viewers also liked (9)

Spring boot
Spring bootSpring boot
Spring boot
 
JHipster, modern web application development made easy
JHipster, modern web application development made easyJHipster, modern web application development made easy
JHipster, modern web application development made easy
 
REST with Spring Boot #jqfk
REST with Spring Boot #jqfkREST with Spring Boot #jqfk
REST with Spring Boot #jqfk
 
Conhecendo API do Facebook
Conhecendo API do FacebookConhecendo API do Facebook
Conhecendo API do Facebook
 
Gestao 2.0 para Fundação Dom Cabral
Gestao 2.0 para Fundação Dom CabralGestao 2.0 para Fundação Dom Cabral
Gestao 2.0 para Fundação Dom Cabral
 
Grails 3.0先取り!? Spring Boot入門ハンズオン #jggug_boot
Grails 3.0先取り!? Spring Boot入門ハンズオン #jggug_bootGrails 3.0先取り!? Spring Boot入門ハンズオン #jggug_boot
Grails 3.0先取り!? Spring Boot入門ハンズオン #jggug_boot
 
Building REST APIs with Spring Boot and Spring Cloud
Building REST APIs with Spring Boot and Spring CloudBuilding REST APIs with Spring Boot and Spring Cloud
Building REST APIs with Spring Boot and Spring Cloud
 
Microservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudMicroservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring Cloud
 
Microservice With Spring Boot and Spring Cloud
Microservice With Spring Boot and Spring CloudMicroservice With Spring Boot and Spring Cloud
Microservice With Spring Boot and Spring Cloud
 

Similar to Building a REST Service in minutes with Spring Boot

Designing your API Server for mobile apps
Designing your API Server for mobile appsDesigning your API Server for mobile apps
Designing your API Server for mobile appsMugunth Kumar
 
MuleSoft Manchester Meetup #3 slides 31st March 2020
MuleSoft Manchester Meetup #3 slides 31st March 2020MuleSoft Manchester Meetup #3 slides 31st March 2020
MuleSoft Manchester Meetup #3 slides 31st March 2020Ieva Navickaite
 
Profiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty DetailsProfiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty DetailsAchievers Tech
 
2019-06 - Goto Amsterdam - Microservices
2019-06 - Goto Amsterdam - Microservices2019-06 - Goto Amsterdam - Microservices
2019-06 - Goto Amsterdam - MicroservicesEamonn Boyle
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLBarry Jones
 
Breaking the Monolith: Organizing Your Team to Embrace Microservices
Breaking the Monolith: Organizing Your Team to Embrace MicroservicesBreaking the Monolith: Organizing Your Team to Embrace Microservices
Breaking the Monolith: Organizing Your Team to Embrace MicroservicesPaul Osman
 
Reactive Programming and REST/JSON for SQL Databases - Microsoft SQL Server M...
Reactive Programming and REST/JSON for SQL Databases - Microsoft SQL Server M...Reactive Programming and REST/JSON for SQL Databases - Microsoft SQL Server M...
Reactive Programming and REST/JSON for SQL Databases - Microsoft SQL Server M...Espresso Logic
 
They why behind php frameworks
They why behind php frameworksThey why behind php frameworks
They why behind php frameworksKirk Madera
 
New Persistence Features in Spring Roo 1.1
New Persistence Features in Spring Roo 1.1New Persistence Features in Spring Roo 1.1
New Persistence Features in Spring Roo 1.1Stefan Schmidt
 
Plone FSR
Plone FSRPlone FSR
Plone FSRfulv
 
OpenNTF Webinar 2022-08 - XPages Jakarta EE Support in Practice
OpenNTF Webinar 2022-08 - XPages Jakarta EE Support in PracticeOpenNTF Webinar 2022-08 - XPages Jakarta EE Support in Practice
OpenNTF Webinar 2022-08 - XPages Jakarta EE Support in PracticeJesse Gallagher
 
First Look at Azure Logic Apps (BAUG)
First Look at Azure Logic Apps (BAUG)First Look at Azure Logic Apps (BAUG)
First Look at Azure Logic Apps (BAUG)Daniel Toomey
 
AngularJSTO presentation
AngularJSTO presentationAngularJSTO presentation
AngularJSTO presentationAlan Hietala
 
How to Build Single Page HTML5 Apps that Scale
How to Build Single Page HTML5 Apps that ScaleHow to Build Single Page HTML5 Apps that Scale
How to Build Single Page HTML5 Apps that ScalePhil Leggetter
 
RESTFul Tools For Lazy Experts - CFSummit 2016
RESTFul Tools For Lazy Experts - CFSummit 2016RESTFul Tools For Lazy Experts - CFSummit 2016
RESTFul Tools For Lazy Experts - CFSummit 2016Ortus Solutions, Corp
 
Powering a Startup with Apache Spark with Kevin Kim
Powering a Startup with Apache Spark with Kevin KimPowering a Startup with Apache Spark with Kevin Kim
Powering a Startup with Apache Spark with Kevin KimSpark Summit
 
From Lucene to Solr 4 Trunk
From Lucene to Solr 4 TrunkFrom Lucene to Solr 4 Trunk
From Lucene to Solr 4 Trunktdthomassld
 
04 integrate entityframework
04 integrate entityframework04 integrate entityframework
04 integrate entityframeworkErhwen Kuo
 
FOSS4G In The Cloud: Using Open Source to build Cloud based Spatial Infrastru...
FOSS4G In The Cloud: Using Open Source to build Cloud based Spatial Infrastru...FOSS4G In The Cloud: Using Open Source to build Cloud based Spatial Infrastru...
FOSS4G In The Cloud: Using Open Source to build Cloud based Spatial Infrastru...Mohamed Sayed
 

Similar to Building a REST Service in minutes with Spring Boot (20)

Designing your API Server for mobile apps
Designing your API Server for mobile appsDesigning your API Server for mobile apps
Designing your API Server for mobile apps
 
MuleSoft Manchester Meetup #3 slides 31st March 2020
MuleSoft Manchester Meetup #3 slides 31st March 2020MuleSoft Manchester Meetup #3 slides 31st March 2020
MuleSoft Manchester Meetup #3 slides 31st March 2020
 
Profiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty DetailsProfiling and Tuning a Web Application - The Dirty Details
Profiling and Tuning a Web Application - The Dirty Details
 
2019-06 - Goto Amsterdam - Microservices
2019-06 - Goto Amsterdam - Microservices2019-06 - Goto Amsterdam - Microservices
2019-06 - Goto Amsterdam - Microservices
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
 
Breaking the Monolith: Organizing Your Team to Embrace Microservices
Breaking the Monolith: Organizing Your Team to Embrace MicroservicesBreaking the Monolith: Organizing Your Team to Embrace Microservices
Breaking the Monolith: Organizing Your Team to Embrace Microservices
 
Reactive Programming and REST/JSON for SQL Databases - Microsoft SQL Server M...
Reactive Programming and REST/JSON for SQL Databases - Microsoft SQL Server M...Reactive Programming and REST/JSON for SQL Databases - Microsoft SQL Server M...
Reactive Programming and REST/JSON for SQL Databases - Microsoft SQL Server M...
 
They why behind php frameworks
They why behind php frameworksThey why behind php frameworks
They why behind php frameworks
 
New Persistence Features in Spring Roo 1.1
New Persistence Features in Spring Roo 1.1New Persistence Features in Spring Roo 1.1
New Persistence Features in Spring Roo 1.1
 
Plone FSR
Plone FSRPlone FSR
Plone FSR
 
OpenNTF Webinar 2022-08 - XPages Jakarta EE Support in Practice
OpenNTF Webinar 2022-08 - XPages Jakarta EE Support in PracticeOpenNTF Webinar 2022-08 - XPages Jakarta EE Support in Practice
OpenNTF Webinar 2022-08 - XPages Jakarta EE Support in Practice
 
First Look at Azure Logic Apps (BAUG)
First Look at Azure Logic Apps (BAUG)First Look at Azure Logic Apps (BAUG)
First Look at Azure Logic Apps (BAUG)
 
AngularJSTO presentation
AngularJSTO presentationAngularJSTO presentation
AngularJSTO presentation
 
How to Build Single Page HTML5 Apps that Scale
How to Build Single Page HTML5 Apps that ScaleHow to Build Single Page HTML5 Apps that Scale
How to Build Single Page HTML5 Apps that Scale
 
Rest ful tools for lazy experts
Rest ful tools for lazy expertsRest ful tools for lazy experts
Rest ful tools for lazy experts
 
RESTFul Tools For Lazy Experts - CFSummit 2016
RESTFul Tools For Lazy Experts - CFSummit 2016RESTFul Tools For Lazy Experts - CFSummit 2016
RESTFul Tools For Lazy Experts - CFSummit 2016
 
Powering a Startup with Apache Spark with Kevin Kim
Powering a Startup with Apache Spark with Kevin KimPowering a Startup with Apache Spark with Kevin Kim
Powering a Startup with Apache Spark with Kevin Kim
 
From Lucene to Solr 4 Trunk
From Lucene to Solr 4 TrunkFrom Lucene to Solr 4 Trunk
From Lucene to Solr 4 Trunk
 
04 integrate entityframework
04 integrate entityframework04 integrate entityframework
04 integrate entityframework
 
FOSS4G In The Cloud: Using Open Source to build Cloud based Spatial Infrastru...
FOSS4G In The Cloud: Using Open Source to build Cloud based Spatial Infrastru...FOSS4G In The Cloud: Using Open Source to build Cloud based Spatial Infrastru...
FOSS4G In The Cloud: Using Open Source to build Cloud based Spatial Infrastru...
 

Recently uploaded

Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 

Building a REST Service in minutes with Spring Boot

  • 1. Spring Boot Building a REST Service in minutes
  • 2. omri.spector@develeap.com I am… • Omri Spector, CEO deveLeap • deveLeap mission – Helping development teams use the right tools, technologies & architecture to achieve their business objective. – Specialize in Java, CI and the JVM eco-system • Omri – Active commercial developer since 1985 – In Java since 2004 – Managed large multi national development groups
  • 3. omri.spector@develeap.com Agenda • What is Spring Boot • Creating a SpringBoot Application • Creating a basic REST Service (POST, GET) • Connecting to a Database • Going forward
  • 4. omri.spector@develeap.com What is Spring boot • Spring • Opinionated • Geared for fast development of robust micro services • Others in this arena – Drop wizard – Play – Vert.x – Jodd – …
  • 5. omri.spector@develeap.com Where would I use SpringBoot? • Green Field – Get new project up & running in no time without compromising architecture and infrastructure • Modernizing Legacy – Gradually modernize legacy monolith applications by moving aspects to Spring Boot “micro-services”
  • 7. omri.spector@develeap.com Starting a project • https://start.spring.io/ – Actuator: “Production Ready” – Web: Web related functionality (e.g. MVC) – Devtools: Hot swap during development – Lombok: “Less boilerplate” Later we can easily add more, e.g. “data”, “cloud”,…
  • 8. omri.spector@develeap.com Alternative start - JHipster • JHipster is a code generation tool that offers a much more comprehensive starting point • It adds opinioned use of the client side stack: Angular, Gulp, SASS, Bower, etc. • It adds many common features and UI out of the box • The amount of code it creates is large – which can be viewed as good or bad
  • 9. omri.spector@develeap.com What we created • Pom – spring boot pom • DemoApplication – – @SpringBootApplication: spring mvc, scanner – Main: embedded tomcat • Resources/static, resources/template • Application.properties (empty) • DemoApplicationTests – context loads, Spring test
  • 10. omri.spector@develeap.com Build & Run • Fat Jar for easy deploy • Actuator endpoints: – /health, – /env, – /metrics, – : • Hot swap
  • 11. omri.spector@develeap.com Chapter 1 – POST, GET • Domain: Simplify with lombok • Services: @Service pojo for all business logic • Controller: @Controller utilizing: – @RequestMapping (hierarchical) – @ResponseBody – to avoid writing views – @RequestBody & @PathVariable on params • PostMan – Post, Get, Get non existing
  • 12. omri.spector@develeap.com Chapter 2 – HTTP Errors • Return 404 using RuntimeException with @ResponseStatus
  • 13. omri.spector@develeap.com Chapter 3 – Working with a DB • Add spring-boot-starter-data-jpa and a db driver • Add a CrudRepository based @Repository • Model object is now and @Entity with an @id – Make sure name matches table name! • Changed service to use it • Configuring the db connection in application properties
  • 14. omri.spector@develeap.com Chapter 4 – Getting a list • Many options, from findAll to HQL to SQL • We will use Spring Data Proxy • Of course this is naïve, and is often improved: – Limiting the fields returned or even defining a “light” version – Adding sort and paging Iterable<Artist> findByNameContaining(String s);
  • 15. omri.spector@develeap.com Chapter 5 – It doesn’t stop here • Spring is a very comprehensive project • Spring-Boot wraps many of it’s aspects and integrates many other successful open source facilities
  • 16. omri.spector@develeap.com Typical additions • Spring Security • Spring Social – Facebook, Twitter, LinkedIn… • Spring Cloud – Service discovery, Circuit breakers, control bus, … • Schema Management – Liquibase, Flyway • Front end assets management – Web jars • Transaction Management • Spring Data – Both Relational and many NoSQL And the list goes on…
  • 17. omri.spector@develeap.com In Summary • Spring boot creates an: – easy to deploy – executable – “fat” jar • Management services out of the box • In several minutes and very little code we get: – REST against a db backend – JPA based ORM – And the spring power to easily add so much more
  • 18. omri.spector@develeap.com Shameless Plug Are you considering the move to “micro-services”? Don’t hesitate to call: omri.spector@develeap.com

Editor's Notes

  1. Devtools in IDE – only when running in debug mode. “Mostly” works. Not as fast or total as Jrebel.
  2. Tomcat alternatives: jetty, undertow, grizzly, …
  3. Note: Fat jar created by maven, not when running from IDE
  4. To add paging: - findByNameContaining(String s, Pageable pageable); and pass PageRequest