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

What's hot (20)

Spring boot
Spring bootSpring boot
Spring boot
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
 
RESTful API - Best Practices
RESTful API - Best PracticesRESTful API - Best Practices
RESTful API - Best Practices
 
Spring boot
Spring bootSpring boot
Spring boot
 
Spring boot
Spring bootSpring boot
Spring boot
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Rest API
Rest APIRest API
Rest API
 
Spring MVC Framework
Spring MVC FrameworkSpring MVC Framework
Spring MVC Framework
 
Spring Framework - MVC
Spring Framework - MVCSpring Framework - MVC
Spring Framework - MVC
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
PUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootPUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBoot
 
An Introduction To REST API
An Introduction To REST APIAn Introduction To REST API
An Introduction To REST API
 
Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UK
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
 
Spring framework Controllers and Annotations
Spring framework   Controllers and AnnotationsSpring framework   Controllers and Annotations
Spring framework Controllers and Annotations
 
Introduction to Spring Boot!
Introduction to Spring Boot!Introduction to Spring Boot!
Introduction to Spring Boot!
 
Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)
 
REST API and CRUD
REST API and CRUDREST API and CRUD
REST API and CRUD
 
Presentation1.pptx
Presentation1.pptxPresentation1.pptx
Presentation1.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

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 

Recently uploaded (20)

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 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