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

Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slidesSpring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slidesHitesh-Java
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introductionRasheed Waraich
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with SpringJoshua Long
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework tola99
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - CoreDzmitry Naskou
 
Spring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
Spring I/O 2012: Natural Templating in Spring MVC with ThymeleafSpring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
Spring I/O 2012: Natural Templating in Spring MVC with ThymeleafThymeleaf
 
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + Expres...
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js +  Expres...Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js +  Expres...
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + Expres...Edureka!
 
Angular 8
Angular 8 Angular 8
Angular 8 Sunil OS
 
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
 
jpa-hibernate-presentation
jpa-hibernate-presentationjpa-hibernate-presentation
jpa-hibernate-presentationJohn Slick
 

What's hot (20)

Spring User Guide
Spring User GuideSpring User Guide
Spring User Guide
 
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slidesSpring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
Spring - Part 2 - Autowiring, Annotations, Java based Configuration - slides
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
Spring boot
Spring bootSpring boot
Spring boot
 
Spring framework core
Spring framework coreSpring framework core
Spring framework core
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
 
Angular
AngularAngular
Angular
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
Spring Core
Spring CoreSpring Core
Spring Core
 
Spring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
Spring I/O 2012: Natural Templating in Spring MVC with ThymeleafSpring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
Spring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
 
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + Expres...
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js +  Expres...Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js +  Expres...
Node.js Express Tutorial | Node.js Tutorial For Beginners | Node.js + Expres...
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
Angular 8
Angular 8 Angular 8
Angular 8
 
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
 
Spring boot jpa
Spring boot jpaSpring boot jpa
Spring boot jpa
 
jpa-hibernate-presentation
jpa-hibernate-presentationjpa-hibernate-presentation
jpa-hibernate-presentation
 
Spring boot
Spring bootSpring boot
Spring boot
 

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
 
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 (8)

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
 
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

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024SynarionITSolutions
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Recently uploaded (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

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