SlideShare a Scribd company logo
Spring Boot -
A Microframework for
Microservices
Nilanjan Roy
What is Spring Boot ?
• Focuses attention at a single point (as opposed to large
collection of spring-* projects)
• A tool for getting started very quickly with Spring
• Common non-functional requirements for a "real" application
• Exposes a lot of useful features by default
• Gets out of the way quickly if you want to change defaults
What is Spring Boot
How Does it help microservices ?
• You are going to write more than one microservice
• That means you are going to do this a lot….
– Declare dependencies
– Configure Spring
– Configure logging
– Load properties file
– Setup monitoring
– Add Security
– Talk to a database
– Add metrics
Spring Boot Modules
Spring Boot Modules
• Spring Boot - main library supporting the other parts of Spring Boot
• Spring Boot Autoconfigure -
single @EnableAutoConfiguration annotation creates a whole Spring
context
• Spring Boot Starters - a set of convenient dependency descriptors that
you can include in your application.
• Spring Boot CLI - compiles and runs Groovy source as a Spring
application
• Spring Boot Actuator - common non-functional features that make an
app instantly deployable and supportable in production
• Spring Boot Tools - for building and executing self-contained JAR and
WAR archives
• Spring Boot Samples - a wide range of sample apps
Spring Boot Starter POMs
Spring Boot Actuator: Production-
ready features
Gaining application insight with
Actuator
• Spring Boot Actuator adds several helpful management endpoints
to a Spring Boot-based application. These endpoints include
• GET /autoconfig —Explains the decisions made by Spring Boot when
applying autoconfiguration
• GET /beans —Catalogs the beans that are configured for the running
application
• GET /configprops —Lists all properties available for configuring the
properties of beans in the application with their current values
• GET /dump —Lists application threads, including a stack trace for
each thread
Gaining application insight with
the Actuator
• GET /env —Lists all environment and system property variables available to
the application context
• GET /env/{name} —Displays the value for a specific environment or
property variable
• GET /health —Displays the current application health
• GET /info —Displays application-specific information
• GET /metrics —Lists metrics concerning the application, including running
counts of requests against certain endpoints
• GET /metrics/{name} —Displays metrics for a specific application metric
key
• POST /shutdown —Forcibly shuts down the application
• GET /trace —Lists metadata concerning recent requests served through the
application, including request and response headers
Extending The Actuator
Extending The Actuator
Monitoring MicroServices
Monitoring MicroServices
Customizing Monitoring Endpoints
• We can change how those endpoints are exposed
using application.properties
– management.port=8081 - you can expose those endpoints on port
other than the one application is using .
– management.address=127.0.0.1 - you can only allow to access by IP
address (localhost here).
– management.context-path=/actuator - allows you to have those
endpoints grouped under specified context path rather than root,
i.e. /actuator/health.
– endpoints.health.enabled=false - allows to enable/disable specified
endpoint by name, here /health is disabled.
Customizing Monitoring Endpoints
• We can change if an endpoint is enabled, if it is considered sensitive and even
its id.
• Following entry in the application.properties that changes the sensitivity and id
of the beans endpoint and also enables shutdown.
endpoints.beans.id=springbeans
endpoints.beans.sensitive=false
endpoints.shutdown.enabled=true
• By default, all endpoints except for shutdown are enabled. If you prefer to
specifically “opt-in” endpoint enablement you can use
the endpoints.enabled property. For example, the following will
disable all endpoints except for info:
endpoints.enabled=false
endpoints.info.enabled=true
Securing Monitoring Endpoints
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
• Disable basic security in application.properties, so that it leaves only the
sensitive Actuator endpoints secured and leaves the rest open for access:
– security.basic.enabled=false
• Set up a new username, or a password if you don't want it to be different on
each start:
– security.user.name=admin
– security.user.password=new_password
• In case you're using the security features across the application and decided to
secure those endpoints yourself, you can disable default security for Actuator:
– management.security.enabled=false
Custom Healthchecks
• Besides checking if the application is UP or DOWN, which is done by
default, you can add checks for things like database connectivity or MQ
status etc.
@Component
public class MyHealth implements HealthIndicator {
@Override
public Health health() {
int errorCode = check(); // perform some specific health check
if (errorCode != 0)
{
return Health.down().withDetail("Error Code",
errorCode).build();
}
return Health.up().build();
}
}
Measure Everything with Metrics
Emitting your own Metrics
• GaugeService :
– A service that can be used to submit a named double value for storage
and analysis.
– For instance, the value submitted here could be a method execution
timing result, and it would go to a backend that keeps a histogram of
recent values for comparison purposes.
• CounterService :
– Increment , decrement or reset an integer value (e.g. number of times
an error was thrown)
Storing Metrics
Logging with Spring Boot
Logging with Spring Boot
• Spring Boot uses Commons Logging for all internal logging, but
leaves the underlying log implementation open. Default
configurations are provided for Java Util Logging,Log4J and Logback.
In each case there is console output and file output (rotating, 10
Mb file size).
• By default, If we use the ‘Starter POMs’, Logback will be used for
logging. Appropriate Logback routing is also included to ensure that
dependent libraries that use Java Util Logging, Commons Logging,
Log4J or SLF4J will all work correctly.
Spring Boot AutoConfiguration
• Spring Boot auto-configuration attempts to automatically configure your
Spring application based on the jar dependencies that you have added.
For example, If HSQLDB is on your classpath, and you have not manually
configured any database connection beans, then it will auto-configure an
in-memory database.
• You need to opt-in to auto-configuration by adding
the @EnableAutoConfiguration or @SpringBootApplication annotations to
one of your @Configurationclasses.
• Disabling AutoConfiguration
@Configuration
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
public class MyConfiguration { }
Understanding AutoConfiguration
Behind the Scene
• There are two parts to it :
1) List of files which has to be considered as
configuration classes
2) When these should be applied
Behind the Scene
• @EnableAutoConfiguration" is a spring-boot(autoconfigure) annotation
which is handled by
org.springframework.boot.autoconfigure.EnableAutoConfigurationImport
Selector.
• In "EnableAutoConfigurationImportSelector", it uses
"org.springframework.core.io.support.SpringFactoriesLoader#loadFactory
Names" from spring-core to load configurations whose key is
"org.springframework.boot.autoconfigure.EnableAutoConfiguration".
• This method reads "META-INF/spring.factories" from jar files.(multiple jar
files can have "spring.factories" and when they have same key, comma
delimited values will be merged.)
Understand @Conditional
Understand “Twelve-Factor App”
style configuration
Understand “Twelve-Factor App”
style configuration
• Spring Boot builds upon propertySource
• It allows you to externalize your configuration so you can work with the
same application code in different environments. You can use properties
files, YAML files, environment variables and command-line arguments to
externalize configuration.
• Spring Boot uses a very particular PropertySource order that is designed
to allow sensible overriding of values, properties are considered in the
following order:
Understand “Twelve-Factor App”
style configuration
Understand “Twelve-Factor App”
style configuration
Set the active Spring profiles :
• Profile-specific application properties outside of your packaged jar
(application-{profile}.properties and YAML variants)
• Profile-specific application properties packaged inside your jar
(application-{profile}.properties and YAML variants)
– Usually set through system profile (spring.profiles.active) or an OS environment variable
(SPRING_PROFILES_ACTIVE).
e.g. $ java -jar -Dspring.profiles.active=production demo-0.0.1-SNAPSHOT.jar
or it can be set in application.properties :
spring.profiles.active=production
Spring FrameWork profiles for
Multiple Environments
Relaxed Bindings
Common application properties
• http://docs.spring.io/spring-
boot/docs/current/reference/html/common-
application-properties.html
Understand “Twelve-Factor App”
style configuration
• @ConfigurationProperties
– A way to map properties to POJO
– Type Safe
– IDE Support
– Can be validated with @Valid
Creates Runnable Fat JARs
The executable jar file structure
example.jar
|
+-META-INF
| +-MANIFEST.MF
+-org
| +-springframework
| +-boot
| +-loader
| +-<spring boot loader classes>
+-com
| +-mycompany
| + project
| +-YouClasses.class
+-lib
+-dependency1.jar
+-dependency2.jar
References & Further readings
• http://docs.spring.io/spring-
boot/docs/current-
SNAPSHOT/reference/htmlsingle/
• http://cloud.spring.io/spring-cloud-netflix/

More Related Content

What's hot

PUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootPUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBoot
Josué Neis
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
Purbarun Chakrabarti
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
Joshua Long
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
07.pallav
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
Alex Movila
 
Xke spring boot
Xke spring bootXke spring boot
Xke spring boot
sourabh aggarwal
 
Mongo db
Mongo dbMongo db
Mongo db
Gyanendra Yadav
 
Building a Spring Boot Application - Ask the Audience!
Building a Spring Boot Application - Ask the Audience!Building a Spring Boot Application - Ask the Audience!
Building a Spring Boot Application - Ask the Audience!
🎤 Hanno Embregts 🎸
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
Naphachara Rattanawilai
 
Introduction to Spring Boot!
Introduction to Spring Boot!Introduction to Spring Boot!
Introduction to Spring Boot!Jakub Kubrynski
 
Gradle - Build System
Gradle - Build SystemGradle - Build System
Gradle - Build System
Jeevesh Pandey
 
The Past Year in Spring for Apache Geode
The Past Year in Spring for Apache GeodeThe Past Year in Spring for Apache Geode
The Past Year in Spring for Apache Geode
VMware Tanzu
 
Spring Boot & WebSocket
Spring Boot & WebSocketSpring Boot & WebSocket
Spring Boot & WebSocketMing-Ying Wu
 
Spring Boot Showcase
Spring Boot ShowcaseSpring Boot Showcase
Spring Boot Showcase
Naphachara Rattanawilai
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with Spring
Joshua Long
 
Springboot2 postgresql-jpa-hibernate-crud-example with test
Springboot2 postgresql-jpa-hibernate-crud-example with testSpringboot2 postgresql-jpa-hibernate-crud-example with test
Springboot2 postgresql-jpa-hibernate-crud-example with test
HyukSun Kwon
 
JavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオンJavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオン
haruki ueno
 
The Spring Update
The Spring UpdateThe Spring Update
The Spring Update
Gunnar Hillert
 
Ansible with oci
Ansible with ociAnsible with oci
Ansible with oci
DonghuKIM2
 
Creating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSCreating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJS
Gunnar Hillert
 

What's hot (20)

PUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootPUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBoot
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
 
Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
 
Xke spring boot
Xke spring bootXke spring boot
Xke spring boot
 
Mongo db
Mongo dbMongo db
Mongo db
 
Building a Spring Boot Application - Ask the Audience!
Building a Spring Boot Application - Ask the Audience!Building a Spring Boot Application - Ask the Audience!
Building a Spring Boot Application - Ask the Audience!
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 
Introduction to Spring Boot!
Introduction to Spring Boot!Introduction to Spring Boot!
Introduction to Spring Boot!
 
Gradle - Build System
Gradle - Build SystemGradle - Build System
Gradle - Build System
 
The Past Year in Spring for Apache Geode
The Past Year in Spring for Apache GeodeThe Past Year in Spring for Apache Geode
The Past Year in Spring for Apache Geode
 
Spring Boot & WebSocket
Spring Boot & WebSocketSpring Boot & WebSocket
Spring Boot & WebSocket
 
Spring Boot Showcase
Spring Boot ShowcaseSpring Boot Showcase
Spring Boot Showcase
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with Spring
 
Springboot2 postgresql-jpa-hibernate-crud-example with test
Springboot2 postgresql-jpa-hibernate-crud-example with testSpringboot2 postgresql-jpa-hibernate-crud-example with test
Springboot2 postgresql-jpa-hibernate-crud-example with test
 
JavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオンJavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオン
 
The Spring Update
The Spring UpdateThe Spring Update
The Spring Update
 
Ansible with oci
Ansible with ociAnsible with oci
Ansible with oci
 
Creating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJSCreating Modular Test-Driven SPAs with Spring and AngularJS
Creating Modular Test-Driven SPAs with Spring and AngularJS
 

Viewers also liked

Developing Agile Java Applications using Spring tools
Developing Agile Java Applications using Spring toolsDeveloping Agile Java Applications using Spring tools
Developing Agile Java Applications using Spring tools
Sathish Chittibabu
 
Introduction to AJAX and DWR
Introduction to AJAX and DWRIntroduction to AJAX and DWR
Introduction to AJAX and DWR
SweNz FixEd
 
Hibernate Training Session1
Hibernate Training Session1Hibernate Training Session1
Hibernate Training Session1Asad Khan
 
JSON-(JavaScript Object Notation)
JSON-(JavaScript Object Notation)JSON-(JavaScript Object Notation)
JSON-(JavaScript Object Notation)
Skillwise Group
 
Hibernate
HibernateHibernate
Hibernate
husnara mohammad
 
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B KuteJava Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Tushar B Kute
 
Spring Boot Actuator
Spring Boot ActuatorSpring Boot Actuator
Spring Boot Actuator
Rowell Belen
 
Spring boot actuator
Spring boot   actuatorSpring boot   actuator
Spring boot actuator
Choonghyun Yang
 
A pattern language for microservices (#gluecon #gluecon2016)
A pattern language for microservices (#gluecon #gluecon2016)A pattern language for microservices (#gluecon #gluecon2016)
A pattern language for microservices (#gluecon #gluecon2016)
Chris Richardson
 
Java & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate FrameworkJava & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate Framework
Mohit Belwal
 
Microservices + Events + Docker = A Perfect Trio (dockercon)
Microservices + Events + Docker = A Perfect Trio (dockercon)Microservices + Events + Docker = A Perfect Trio (dockercon)
Microservices + Events + Docker = A Perfect Trio (dockercon)
Chris Richardson
 
Developing microservices with aggregates (SpringOne platform, #s1p)
Developing microservices with aggregates (SpringOne platform, #s1p)Developing microservices with aggregates (SpringOne platform, #s1p)
Developing microservices with aggregates (SpringOne platform, #s1p)
Chris Richardson
 
Lecture 4: JavaServer Pages (JSP) & Expression Language (EL)
Lecture 4:  JavaServer Pages (JSP) & Expression Language (EL)Lecture 4:  JavaServer Pages (JSP) & Expression Language (EL)
Lecture 4: JavaServer Pages (JSP) & Expression Language (EL)
Fahad Golra
 
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
Chris Richardson
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
Tanmoy Barman
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
Dzmitry Naskou
 
Spring boot
Spring bootSpring boot
Spring boot
sdeeg
 

Viewers also liked (19)

Developing Agile Java Applications using Spring tools
Developing Agile Java Applications using Spring toolsDeveloping Agile Java Applications using Spring tools
Developing Agile Java Applications using Spring tools
 
Introduction to AJAX and DWR
Introduction to AJAX and DWRIntroduction to AJAX and DWR
Introduction to AJAX and DWR
 
Hibernate Training Session1
Hibernate Training Session1Hibernate Training Session1
Hibernate Training Session1
 
JSON-(JavaScript Object Notation)
JSON-(JavaScript Object Notation)JSON-(JavaScript Object Notation)
JSON-(JavaScript Object Notation)
 
Hibernate
HibernateHibernate
Hibernate
 
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B KuteJava Servlet Programming under Ubuntu Linux by Tushar B Kute
Java Servlet Programming under Ubuntu Linux by Tushar B Kute
 
Spring Boot Actuator
Spring Boot ActuatorSpring Boot Actuator
Spring Boot Actuator
 
Maven Overview
Maven OverviewMaven Overview
Maven Overview
 
Spring boot actuator
Spring boot   actuatorSpring boot   actuator
Spring boot actuator
 
A pattern language for microservices (#gluecon #gluecon2016)
A pattern language for microservices (#gluecon #gluecon2016)A pattern language for microservices (#gluecon #gluecon2016)
A pattern language for microservices (#gluecon #gluecon2016)
 
Java & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate FrameworkJava & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate Framework
 
Json
JsonJson
Json
 
Microservices + Events + Docker = A Perfect Trio (dockercon)
Microservices + Events + Docker = A Perfect Trio (dockercon)Microservices + Events + Docker = A Perfect Trio (dockercon)
Microservices + Events + Docker = A Perfect Trio (dockercon)
 
Developing microservices with aggregates (SpringOne platform, #s1p)
Developing microservices with aggregates (SpringOne platform, #s1p)Developing microservices with aggregates (SpringOne platform, #s1p)
Developing microservices with aggregates (SpringOne platform, #s1p)
 
Lecture 4: JavaServer Pages (JSP) & Expression Language (EL)
Lecture 4:  JavaServer Pages (JSP) & Expression Language (EL)Lecture 4:  JavaServer Pages (JSP) & Expression Language (EL)
Lecture 4: JavaServer Pages (JSP) & Expression Language (EL)
 
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
Spring boot
Spring bootSpring boot
Spring boot
 

Similar to Spring boot for buidling microservices

Spring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applicationsSpring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applications
michaelaaron25322
 
Externalized Distributed Configuration Management with Spring Cloud Config-Se...
Externalized Distributed Configuration Management with Spring Cloud Config-Se...Externalized Distributed Configuration Management with Spring Cloud Config-Se...
Externalized Distributed Configuration Management with Spring Cloud Config-Se...
Nikhil Hiremath
 
Spring boot wednesday
Spring boot wednesdaySpring boot wednesday
Spring boot wednesday
Vinay Prajapati
 
Module 6 _ Spring Boot for java application to begin
Module 6 _ Spring Boot for java application to beginModule 6 _ Spring Boot for java application to begin
Module 6 _ Spring Boot for java application to begin
Deepakprasad838637
 
Spring Boot
Spring BootSpring Boot
Spring Boot
Jaydeep Kale
 
Spring Boot & Actuators
Spring Boot & ActuatorsSpring Boot & Actuators
Spring Boot & Actuators
VMware Tanzu
 
Spring Boot. Boot up your development
Spring Boot. Boot up your developmentSpring Boot. Boot up your development
Spring Boot. Boot up your development
Strannik_2013
 
Spring Boot
Spring BootSpring Boot
Spring Boot
Jaran Flaath
 
Spring Boot. Boot up your development. JEEConf 2015
Spring Boot. Boot up your development. JEEConf 2015Spring Boot. Boot up your development. JEEConf 2015
Spring Boot. Boot up your development. JEEConf 2015
Strannik_2013
 
Spring boot
Spring bootSpring boot
Spring boot
Gyanendra Yadav
 
"Spring Boot. Boot up your development" Сергей Моренец
"Spring Boot. Boot up your development" Сергей Моренец"Spring Boot. Boot up your development" Сергей Моренец
"Spring Boot. Boot up your development" Сергей Моренец
Fwdays
 
Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)Gunith Devasurendra
 
Gain Proficiency in Batch Processing with Spring Batch
Gain Proficiency in Batch Processing with Spring BatchGain Proficiency in Batch Processing with Spring Batch
Gain Proficiency in Batch Processing with Spring Batch
Inexture Solutions
 
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdf
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdfdokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdf
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdf
Appster1
 
dokumen.tips_rediscovering-spring-with-spring-boot1.pdf
dokumen.tips_rediscovering-spring-with-spring-boot1.pdfdokumen.tips_rediscovering-spring-with-spring-boot1.pdf
dokumen.tips_rediscovering-spring-with-spring-boot1.pdf
Appster1
 
Bootify your spring application
Bootify your spring applicationBootify your spring application
Bootify your spring application
Jimmy Lu
 
Spring Batch
Spring BatchSpring Batch
Spring Batch
Jayasree Perilakkalam
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
Lars Vogel
 
Springboot - A milestone framework in Java Development
Springboot - A milestone framework in Java DevelopmentSpringboot - A milestone framework in Java Development
Springboot - A milestone framework in Java Development
Expeed Software
 
Fusion Applications Administration Overview
Fusion Applications Administration OverviewFusion Applications Administration Overview
Fusion Applications Administration OverviewVihangAstik
 

Similar to Spring boot for buidling microservices (20)

Spring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applicationsSpring data jpa are used to develop spring applications
Spring data jpa are used to develop spring applications
 
Externalized Distributed Configuration Management with Spring Cloud Config-Se...
Externalized Distributed Configuration Management with Spring Cloud Config-Se...Externalized Distributed Configuration Management with Spring Cloud Config-Se...
Externalized Distributed Configuration Management with Spring Cloud Config-Se...
 
Spring boot wednesday
Spring boot wednesdaySpring boot wednesday
Spring boot wednesday
 
Module 6 _ Spring Boot for java application to begin
Module 6 _ Spring Boot for java application to beginModule 6 _ Spring Boot for java application to begin
Module 6 _ Spring Boot for java application to begin
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring Boot & Actuators
Spring Boot & ActuatorsSpring Boot & Actuators
Spring Boot & Actuators
 
Spring Boot. Boot up your development
Spring Boot. Boot up your developmentSpring Boot. Boot up your development
Spring Boot. Boot up your development
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring Boot. Boot up your development. JEEConf 2015
Spring Boot. Boot up your development. JEEConf 2015Spring Boot. Boot up your development. JEEConf 2015
Spring Boot. Boot up your development. JEEConf 2015
 
Spring boot
Spring bootSpring boot
Spring boot
 
"Spring Boot. Boot up your development" Сергей Моренец
"Spring Boot. Boot up your development" Сергей Моренец"Spring Boot. Boot up your development" Сергей Моренец
"Spring Boot. Boot up your development" Сергей Моренец
 
Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)
 
Gain Proficiency in Batch Processing with Spring Batch
Gain Proficiency in Batch Processing with Spring BatchGain Proficiency in Batch Processing with Spring Batch
Gain Proficiency in Batch Processing with Spring Batch
 
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdf
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdfdokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdf
dokumen.tips_rediscovering-spring-with-spring-boot1 (1).pdf
 
dokumen.tips_rediscovering-spring-with-spring-boot1.pdf
dokumen.tips_rediscovering-spring-with-spring-boot1.pdfdokumen.tips_rediscovering-spring-with-spring-boot1.pdf
dokumen.tips_rediscovering-spring-with-spring-boot1.pdf
 
Bootify your spring application
Bootify your spring applicationBootify your spring application
Bootify your spring application
 
Spring Batch
Spring BatchSpring Batch
Spring Batch
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
 
Springboot - A milestone framework in Java Development
Springboot - A milestone framework in Java DevelopmentSpringboot - A milestone framework in Java Development
Springboot - A milestone framework in Java Development
 
Fusion Applications Administration Overview
Fusion Applications Administration OverviewFusion Applications Administration Overview
Fusion Applications Administration Overview
 

Recently uploaded

Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 

Recently uploaded (20)

Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 

Spring boot for buidling microservices

  • 1. Spring Boot - A Microframework for Microservices Nilanjan Roy
  • 2. What is Spring Boot ? • Focuses attention at a single point (as opposed to large collection of spring-* projects) • A tool for getting started very quickly with Spring • Common non-functional requirements for a "real" application • Exposes a lot of useful features by default • Gets out of the way quickly if you want to change defaults
  • 4. How Does it help microservices ? • You are going to write more than one microservice • That means you are going to do this a lot…. – Declare dependencies – Configure Spring – Configure logging – Load properties file – Setup monitoring – Add Security – Talk to a database – Add metrics
  • 6. Spring Boot Modules • Spring Boot - main library supporting the other parts of Spring Boot • Spring Boot Autoconfigure - single @EnableAutoConfiguration annotation creates a whole Spring context • Spring Boot Starters - a set of convenient dependency descriptors that you can include in your application. • Spring Boot CLI - compiles and runs Groovy source as a Spring application • Spring Boot Actuator - common non-functional features that make an app instantly deployable and supportable in production • Spring Boot Tools - for building and executing self-contained JAR and WAR archives • Spring Boot Samples - a wide range of sample apps
  • 8. Spring Boot Actuator: Production- ready features
  • 9. Gaining application insight with Actuator • Spring Boot Actuator adds several helpful management endpoints to a Spring Boot-based application. These endpoints include • GET /autoconfig —Explains the decisions made by Spring Boot when applying autoconfiguration • GET /beans —Catalogs the beans that are configured for the running application • GET /configprops —Lists all properties available for configuring the properties of beans in the application with their current values • GET /dump —Lists application threads, including a stack trace for each thread
  • 10. Gaining application insight with the Actuator • GET /env —Lists all environment and system property variables available to the application context • GET /env/{name} —Displays the value for a specific environment or property variable • GET /health —Displays the current application health • GET /info —Displays application-specific information • GET /metrics —Lists metrics concerning the application, including running counts of requests against certain endpoints • GET /metrics/{name} —Displays metrics for a specific application metric key • POST /shutdown —Forcibly shuts down the application • GET /trace —Lists metadata concerning recent requests served through the application, including request and response headers
  • 15. Customizing Monitoring Endpoints • We can change how those endpoints are exposed using application.properties – management.port=8081 - you can expose those endpoints on port other than the one application is using . – management.address=127.0.0.1 - you can only allow to access by IP address (localhost here). – management.context-path=/actuator - allows you to have those endpoints grouped under specified context path rather than root, i.e. /actuator/health. – endpoints.health.enabled=false - allows to enable/disable specified endpoint by name, here /health is disabled.
  • 16. Customizing Monitoring Endpoints • We can change if an endpoint is enabled, if it is considered sensitive and even its id. • Following entry in the application.properties that changes the sensitivity and id of the beans endpoint and also enables shutdown. endpoints.beans.id=springbeans endpoints.beans.sensitive=false endpoints.shutdown.enabled=true • By default, all endpoints except for shutdown are enabled. If you prefer to specifically “opt-in” endpoint enablement you can use the endpoints.enabled property. For example, the following will disable all endpoints except for info: endpoints.enabled=false endpoints.info.enabled=true
  • 17. Securing Monitoring Endpoints <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> • Disable basic security in application.properties, so that it leaves only the sensitive Actuator endpoints secured and leaves the rest open for access: – security.basic.enabled=false • Set up a new username, or a password if you don't want it to be different on each start: – security.user.name=admin – security.user.password=new_password • In case you're using the security features across the application and decided to secure those endpoints yourself, you can disable default security for Actuator: – management.security.enabled=false
  • 18. Custom Healthchecks • Besides checking if the application is UP or DOWN, which is done by default, you can add checks for things like database connectivity or MQ status etc. @Component public class MyHealth implements HealthIndicator { @Override public Health health() { int errorCode = check(); // perform some specific health check if (errorCode != 0) { return Health.down().withDetail("Error Code", errorCode).build(); } return Health.up().build(); } }
  • 20. Emitting your own Metrics • GaugeService : – A service that can be used to submit a named double value for storage and analysis. – For instance, the value submitted here could be a method execution timing result, and it would go to a backend that keeps a histogram of recent values for comparison purposes. • CounterService : – Increment , decrement or reset an integer value (e.g. number of times an error was thrown)
  • 23. Logging with Spring Boot • Spring Boot uses Commons Logging for all internal logging, but leaves the underlying log implementation open. Default configurations are provided for Java Util Logging,Log4J and Logback. In each case there is console output and file output (rotating, 10 Mb file size). • By default, If we use the ‘Starter POMs’, Logback will be used for logging. Appropriate Logback routing is also included to ensure that dependent libraries that use Java Util Logging, Commons Logging, Log4J or SLF4J will all work correctly.
  • 24. Spring Boot AutoConfiguration • Spring Boot auto-configuration attempts to automatically configure your Spring application based on the jar dependencies that you have added. For example, If HSQLDB is on your classpath, and you have not manually configured any database connection beans, then it will auto-configure an in-memory database. • You need to opt-in to auto-configuration by adding the @EnableAutoConfiguration or @SpringBootApplication annotations to one of your @Configurationclasses. • Disabling AutoConfiguration @Configuration @EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class}) public class MyConfiguration { }
  • 26. Behind the Scene • There are two parts to it : 1) List of files which has to be considered as configuration classes 2) When these should be applied
  • 27. Behind the Scene • @EnableAutoConfiguration" is a spring-boot(autoconfigure) annotation which is handled by org.springframework.boot.autoconfigure.EnableAutoConfigurationImport Selector. • In "EnableAutoConfigurationImportSelector", it uses "org.springframework.core.io.support.SpringFactoriesLoader#loadFactory Names" from spring-core to load configurations whose key is "org.springframework.boot.autoconfigure.EnableAutoConfiguration". • This method reads "META-INF/spring.factories" from jar files.(multiple jar files can have "spring.factories" and when they have same key, comma delimited values will be merged.)
  • 30. Understand “Twelve-Factor App” style configuration • Spring Boot builds upon propertySource • It allows you to externalize your configuration so you can work with the same application code in different environments. You can use properties files, YAML files, environment variables and command-line arguments to externalize configuration. • Spring Boot uses a very particular PropertySource order that is designed to allow sensible overriding of values, properties are considered in the following order:
  • 32. Understand “Twelve-Factor App” style configuration Set the active Spring profiles : • Profile-specific application properties outside of your packaged jar (application-{profile}.properties and YAML variants) • Profile-specific application properties packaged inside your jar (application-{profile}.properties and YAML variants) – Usually set through system profile (spring.profiles.active) or an OS environment variable (SPRING_PROFILES_ACTIVE). e.g. $ java -jar -Dspring.profiles.active=production demo-0.0.1-SNAPSHOT.jar or it can be set in application.properties : spring.profiles.active=production
  • 33. Spring FrameWork profiles for Multiple Environments
  • 35. Common application properties • http://docs.spring.io/spring- boot/docs/current/reference/html/common- application-properties.html
  • 36. Understand “Twelve-Factor App” style configuration • @ConfigurationProperties – A way to map properties to POJO – Type Safe – IDE Support – Can be validated with @Valid
  • 38. The executable jar file structure example.jar | +-META-INF | +-MANIFEST.MF +-org | +-springframework | +-boot | +-loader | +-<spring boot loader classes> +-com | +-mycompany | + project | +-YouClasses.class +-lib +-dependency1.jar +-dependency2.jar
  • 39. References & Further readings • http://docs.spring.io/spring- boot/docs/current- SNAPSHOT/reference/htmlsingle/ • http://cloud.spring.io/spring-cloud-netflix/