SlideShare a Scribd company logo
1 of 32
Spring Boot
Code with 0% Configuration
Gyenendra Yadav
Jindal InfoSolutions
Introduction – pivotal Say…
 Spring Boot makes it easy to create stand-alone,
production-grade Spring based Applications that you can
“just run”. We take an opinionated view of the Spring
platform and third-party libraries so you can get started
with minimum fuss. Most Spring Boot applications need
very little Spring configuration.
 You can use Spring Boot to create Java applications that
can be started using java -jar or more traditional war
deployments. We also provide a command line tool that
runs “spring scripts”.
WHY We Need Spring Boot?
 Spring Boot is next generation attempt to easy spring setup.
 Spring Boot’s main benefit is configuring the resources based on
what it finds in the classpath.
 If your Maven POM includes JPA dependencies and a MYSQL
driver, then Spring Boot will setup a persistence unit based on
MySQL. If you’ve added a web dependency, then you will get
Spring MVC configured with defaults.
 When we talk about defaults, Spring Boot has its own opinions.
If you are not specifying the details, it will use its own default
configurations. If you want persistence, but don’t specify
anything else in your POM file, then Spring Boot configures
Hibernate as a JPA provider with an HSQLDB database.
primary goals
 To provide a radically faster and widely accessible getting
started development experience for all Spring
development. Since spring community has evolved so big,
it is time to re-invent the way how spring applications are
deployed in much quicker turn around time.
 To be get started so quickely using the default values
which are supported out of the box in the Spring Boot
configurations.
 To provide bunch of non-functional features/solutions that
are very much common to large scale projects (e.g.
embedded servers, security, metrics, health checks,
externalized configuration).
What Spring Boot brings to the table ?
 Convention over configuration
 Standardization for Microservices
 Integrated Server for Development
 Cloud Support
 Adapt & Support for 3rd Party Library
Spring Boot Components
Spring Boot Auto Configure
 Module to auto configure a wide range of Spring projects.
 It will detect availability of certain frameworks (Spring
Batch, Spring Data JPA, Hibernate, JDBC).
 When detected it will try to auto configure that
framework with some sensible defaults, which in general
can be overridden by configuration in an
application.properties/yml(yaml-data serialization
language) file.
Spring Boot Core
The base for other modules, but it also provides
some functionality that can be used on its own, eg.
using command line arguments and YAML files as
Spring Environment property sources and
automatically binding environment properties to
Spring bean properties (with validation).
Spring Boot CLI
A command line interface, based on ruby, to
start/stop spring boot created applications.
Spring Boot Actuator
 This project, when added, will enable certain
enterprise features (Security, Metrics, Default
Error pages) to your application.
 As the auto configure module it uses auto
detection to detect certain frameworks/features
of your application. For an example, you can see
all the REST Services defined in a web application
using Actuator.
Spring Boot Starters
 Different quick start projects to include as a
dependency in your maven or gradle build file.
 It will have the needed dependencies for that
type of application.
 Currently there are many starter projects and
many more are expected to be added.
Spring Boot Tools
 The Maven and Gradle build tool as well as the
custom Spring Boot Loader (used in the single
executable jar/war) is included in this project.
How to use Spring Boot
 You can use spring initialize to create the initial setup. You can visit
either start.spring.io or use STS (Spring Tool Suite) Support available
in IDEA or Eclipse to choose all the Spring Boot Starters
 You need to also choose whether to use Maven or Gradle as the build
tool.
 If you are using start.spring.io, you need to then download the zip and
configure your workspace. Otherwise using your preferred IDE will
automatically create the required file in the workspace.
 Add your code as required
 You can either use mvn clean package or use IDEA or Eclipse to build
and create the jar file.
 By default the JAR would include integrated Tomcat server, so just by
executing the JAR you should be able to use your program.
Environment Setup for Eclipse
Create Project
 Goto Window Menu -> Perspective ->Spring
 Goto File Menu ->New -> Spring Starter Project
MyAppApplication Class
package com.apps;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class MyAppApplication {
public static void main(String[] args) {
SpringApplication.run(MyAppApplication.class, args);
}
}
@SpringBootApplication annotation
 @SpringBootApplication annotation
 Many Spring Boot developers always have their main class
annotated with @Configuration, @EnableAutoConfiguration and
@ComponentScan. Since these annotations are so frequently
used together (especially if you follow the best practices
above), Spring Boot provides a convenient
@SpringBootApplication alternative.
 The @SpringBootApplication annotation is equivalent to using
@Configuration, @EnableAutoConfiguration and
@ComponentScan with their default attributes:
SpringApplication.run()
 You need to run Application.run() because this method starts whole Spring
Framework. Code below integrates your main() with Spring Boot.
 public class SpringApplication extends Object
 Classes that can be used to bootstrap and launch a Spring application from a Java
main method. By default class will perform the following steps to bootstrap your
application:
 Create an appropriate ApplicationContext instance (depending on your classpath)
 Register a CommandLinePropertySource to expose command line arguments as Spring
properties
 Refresh the application context, loading all singleton beans
 Trigger any CommandLineRunner beans
 In most circumstances the static run(Object, String[]) method can be called
directly from your main method to bootstrap your application:
application.properties File
 spring.datasource.url=jdbc:mysql://localhost:3306/springboot
 spring.datasource.username=admin
 spring.datasource.password=admin
 spring.datasource.driver-class-name=com.mysql.jdbc.Driver
 # Allows Hibernate to generate SQL optimized for a particular DBMS
 spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Di
alect
 # Number of ms to wait before throwing an exception if no connection
is available.
 spring.datasource.tomcat.max-wait=10000
 # Maximum no of active conn that can be allocated from this pool at the
same time.
 spring.datasource.tomcat.max-active=50
 # Validate the connection before borrowing it from the pool.
 spring.datasource.tomcat.test-on-borrow=true
Continue…….
 # Keep the connection alive if idle for a long time (needed in production)
 spring.datasource.dbcp.test-while-idle=true
 spring.datasource.dbcp.validation-query=SELECT 1
 # Naming strategy
 spring.jpa.hibernate.naming.strategy=org.hibernate.cfg.ImprovedNamingStrategy
 # Hibernate ddl auto (create, create-drop, update): with "update" the database
 # schema will be automatically updated accordingly to java entities found in
 # the project
 spring.jpa.hibernate.ddl-auto=update
 # Show or not log for each sql query
 spring.jpa.show-sql = true
Load Custom Application Context
package com.apps;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@ImportResource("applicationContext.xml")
public class MyAppApplication {
public static void main(String[] args) {
SpringApplication.run(MyAppApplication.class, args);
}
}
Thank you
 References
 http://docs.spring.io/spring-boot/docs/2.0.x-SNAPSHOT/reference/html/
 http://www.adeveloperdiary.com/java/spring-boot/an-introduction-to-spring-
boot/
 Assignment For you
 Configure yourself
 How to create jar for deployment on production server

More Related Content

What's hot

What's hot (20)

Spring Boot in Action
Spring Boot in Action Spring Boot in Action
Spring Boot in Action
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
Spring boot
Spring bootSpring boot
Spring boot
 
Spring boot Introduction
Spring boot IntroductionSpring boot Introduction
Spring boot Introduction
 
Spring boot
Spring bootSpring boot
Spring boot
 
Introduction to Spring Framework
Introduction to Spring FrameworkIntroduction to Spring Framework
Introduction to Spring Framework
 
Spring Framework - Core
Spring Framework - CoreSpring Framework - Core
Spring Framework - Core
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Xke spring boot
Xke spring bootXke spring boot
Xke spring boot
 
Spring Framework
Spring Framework  Spring Framework
Spring Framework
 
Spring ppt
Spring pptSpring ppt
Spring ppt
 
PUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBootPUC SE Day 2019 - SpringBoot
PUC SE Day 2019 - SpringBoot
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOP
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring Core
Spring CoreSpring Core
Spring Core
 
Spring MVC Framework
Spring MVC FrameworkSpring MVC Framework
Spring MVC Framework
 
Java Spring Framework
Java Spring FrameworkJava Spring Framework
Java Spring Framework
 
Spring boot jpa
Spring boot jpaSpring boot jpa
Spring boot jpa
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
 

Similar to Spring Boot Code with 0% Configuration

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 applicationsmichaelaaron25322
 
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 beginDeepakprasad838637
 
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 🎸
 
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 testHyukSun Kwon
 
Building a Spring Boot Application - Ask the Audience! (from JavaLand 2017)
Building a Spring Boot Application - Ask the Audience!  (from JavaLand 2017)Building a Spring Boot Application - Ask the Audience!  (from JavaLand 2017)
Building a Spring Boot Application - Ask the Audience! (from JavaLand 2017)🎤 Hanno Embregts 🎸
 
Spring Boot Whirlwind Tour
Spring Boot Whirlwind TourSpring Boot Whirlwind Tour
Spring Boot Whirlwind TourVMware Tanzu
 
dokumen.tips_introduction-to-spring-boot-58bb649a21ce5.pptx
dokumen.tips_introduction-to-spring-boot-58bb649a21ce5.pptxdokumen.tips_introduction-to-spring-boot-58bb649a21ce5.pptx
dokumen.tips_introduction-to-spring-boot-58bb649a21ce5.pptxAppster1
 
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
 
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).pdfAppster1
 
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.pdfAppster1
 
Building a Spring Boot Application - Ask the Audience! (from JVMCon 2018)
Building a Spring Boot Application - Ask the Audience! (from JVMCon 2018)Building a Spring Boot Application - Ask the Audience! (from JVMCon 2018)
Building a Spring Boot Application - Ask the Audience! (from JVMCon 2018)🎤 Hanno Embregts 🎸
 
Springboot2 postgresql-jpa-hibernate-crud-example
Springboot2 postgresql-jpa-hibernate-crud-exampleSpringboot2 postgresql-jpa-hibernate-crud-example
Springboot2 postgresql-jpa-hibernate-crud-exampleHyukSun Kwon
 
SpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptxSpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptxSUFYAN SATTAR
 
Spring boot vs spring framework razor sharp web applications
Spring boot vs spring framework razor sharp web applicationsSpring boot vs spring framework razor sharp web applications
Spring boot vs spring framework razor sharp web applicationsKaty Slemon
 
Spring boot.pptx
Spring boot.pptxSpring boot.pptx
Spring boot.pptxKartikSang2
 
Spring boot for buidling microservices
Spring boot for buidling microservicesSpring boot for buidling microservices
Spring boot for buidling microservicesNilanjan Roy
 

Similar to Spring Boot Code with 0% Configuration (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
 
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
 
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!
 
Springboot2 postgresql-jpa-hibernate-crud-example with test
Springboot2 postgresql-jpa-hibernate-crud-example with testSpringboot2 postgresql-jpa-hibernate-crud-example with test
Springboot2 postgresql-jpa-hibernate-crud-example with test
 
Building a Spring Boot Application - Ask the Audience! (from JavaLand 2017)
Building a Spring Boot Application - Ask the Audience!  (from JavaLand 2017)Building a Spring Boot Application - Ask the Audience!  (from JavaLand 2017)
Building a Spring Boot Application - Ask the Audience! (from JavaLand 2017)
 
Spring Boot Whirlwind Tour
Spring Boot Whirlwind TourSpring Boot Whirlwind Tour
Spring Boot Whirlwind Tour
 
dokumen.tips_introduction-to-spring-boot-58bb649a21ce5.pptx
dokumen.tips_introduction-to-spring-boot-58bb649a21ce5.pptxdokumen.tips_introduction-to-spring-boot-58bb649a21ce5.pptx
dokumen.tips_introduction-to-spring-boot-58bb649a21ce5.pptx
 
Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)Rediscovering Spring with Spring Boot(1)
Rediscovering Spring with Spring Boot(1)
 
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
 
Building a Spring Boot Application - Ask the Audience! (from JVMCon 2018)
Building a Spring Boot Application - Ask the Audience! (from JVMCon 2018)Building a Spring Boot Application - Ask the Audience! (from JVMCon 2018)
Building a Spring Boot Application - Ask the Audience! (from JVMCon 2018)
 
Spring boot
Spring bootSpring boot
Spring boot
 
Springboot2 postgresql-jpa-hibernate-crud-example
Springboot2 postgresql-jpa-hibernate-crud-exampleSpringboot2 postgresql-jpa-hibernate-crud-example
Springboot2 postgresql-jpa-hibernate-crud-example
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Spring competitive tests
Spring competitive testsSpring competitive tests
Spring competitive tests
 
SpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptxSpringBootCompleteBootcamp.pptx
SpringBootCompleteBootcamp.pptx
 
Spring boot vs spring framework razor sharp web applications
Spring boot vs spring framework razor sharp web applicationsSpring boot vs spring framework razor sharp web applications
Spring boot vs spring framework razor sharp web applications
 
Spring boot.pptx
Spring boot.pptxSpring boot.pptx
Spring boot.pptx
 
1.introduction to java
1.introduction to java1.introduction to java
1.introduction to java
 
Spring boot for buidling microservices
Spring boot for buidling microservicesSpring boot for buidling microservices
Spring boot for buidling microservices
 

Recently uploaded

(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 

Recently uploaded (20)

Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 

Spring Boot Code with 0% Configuration

  • 1. Spring Boot Code with 0% Configuration Gyenendra Yadav Jindal InfoSolutions
  • 2. Introduction – pivotal Say…  Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can “just run”. We take an opinionated view of the Spring platform and third-party libraries so you can get started with minimum fuss. Most Spring Boot applications need very little Spring configuration.  You can use Spring Boot to create Java applications that can be started using java -jar or more traditional war deployments. We also provide a command line tool that runs “spring scripts”.
  • 3.
  • 4. WHY We Need Spring Boot?  Spring Boot is next generation attempt to easy spring setup.  Spring Boot’s main benefit is configuring the resources based on what it finds in the classpath.  If your Maven POM includes JPA dependencies and a MYSQL driver, then Spring Boot will setup a persistence unit based on MySQL. If you’ve added a web dependency, then you will get Spring MVC configured with defaults.  When we talk about defaults, Spring Boot has its own opinions. If you are not specifying the details, it will use its own default configurations. If you want persistence, but don’t specify anything else in your POM file, then Spring Boot configures Hibernate as a JPA provider with an HSQLDB database.
  • 5. primary goals  To provide a radically faster and widely accessible getting started development experience for all Spring development. Since spring community has evolved so big, it is time to re-invent the way how spring applications are deployed in much quicker turn around time.  To be get started so quickely using the default values which are supported out of the box in the Spring Boot configurations.  To provide bunch of non-functional features/solutions that are very much common to large scale projects (e.g. embedded servers, security, metrics, health checks, externalized configuration).
  • 6. What Spring Boot brings to the table ?  Convention over configuration  Standardization for Microservices  Integrated Server for Development  Cloud Support  Adapt & Support for 3rd Party Library
  • 8. Spring Boot Auto Configure  Module to auto configure a wide range of Spring projects.  It will detect availability of certain frameworks (Spring Batch, Spring Data JPA, Hibernate, JDBC).  When detected it will try to auto configure that framework with some sensible defaults, which in general can be overridden by configuration in an application.properties/yml(yaml-data serialization language) file.
  • 9. Spring Boot Core The base for other modules, but it also provides some functionality that can be used on its own, eg. using command line arguments and YAML files as Spring Environment property sources and automatically binding environment properties to Spring bean properties (with validation).
  • 10. Spring Boot CLI A command line interface, based on ruby, to start/stop spring boot created applications.
  • 11. Spring Boot Actuator  This project, when added, will enable certain enterprise features (Security, Metrics, Default Error pages) to your application.  As the auto configure module it uses auto detection to detect certain frameworks/features of your application. For an example, you can see all the REST Services defined in a web application using Actuator.
  • 12. Spring Boot Starters  Different quick start projects to include as a dependency in your maven or gradle build file.  It will have the needed dependencies for that type of application.  Currently there are many starter projects and many more are expected to be added.
  • 13. Spring Boot Tools  The Maven and Gradle build tool as well as the custom Spring Boot Loader (used in the single executable jar/war) is included in this project.
  • 14. How to use Spring Boot  You can use spring initialize to create the initial setup. You can visit either start.spring.io or use STS (Spring Tool Suite) Support available in IDEA or Eclipse to choose all the Spring Boot Starters  You need to also choose whether to use Maven or Gradle as the build tool.  If you are using start.spring.io, you need to then download the zip and configure your workspace. Otherwise using your preferred IDE will automatically create the required file in the workspace.  Add your code as required  You can either use mvn clean package or use IDEA or Eclipse to build and create the jar file.  By default the JAR would include integrated Tomcat server, so just by executing the JAR you should be able to use your program.
  • 15.
  • 17.
  • 18.
  • 19. Create Project  Goto Window Menu -> Perspective ->Spring  Goto File Menu ->New -> Spring Starter Project
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25. MyAppApplication Class package com.apps; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class MyAppApplication { public static void main(String[] args) { SpringApplication.run(MyAppApplication.class, args); } }
  • 26. @SpringBootApplication annotation  @SpringBootApplication annotation  Many Spring Boot developers always have their main class annotated with @Configuration, @EnableAutoConfiguration and @ComponentScan. Since these annotations are so frequently used together (especially if you follow the best practices above), Spring Boot provides a convenient @SpringBootApplication alternative.  The @SpringBootApplication annotation is equivalent to using @Configuration, @EnableAutoConfiguration and @ComponentScan with their default attributes:
  • 27. SpringApplication.run()  You need to run Application.run() because this method starts whole Spring Framework. Code below integrates your main() with Spring Boot.  public class SpringApplication extends Object  Classes that can be used to bootstrap and launch a Spring application from a Java main method. By default class will perform the following steps to bootstrap your application:  Create an appropriate ApplicationContext instance (depending on your classpath)  Register a CommandLinePropertySource to expose command line arguments as Spring properties  Refresh the application context, loading all singleton beans  Trigger any CommandLineRunner beans  In most circumstances the static run(Object, String[]) method can be called directly from your main method to bootstrap your application:
  • 28. application.properties File  spring.datasource.url=jdbc:mysql://localhost:3306/springboot  spring.datasource.username=admin  spring.datasource.password=admin  spring.datasource.driver-class-name=com.mysql.jdbc.Driver  # Allows Hibernate to generate SQL optimized for a particular DBMS  spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Di alect  # Number of ms to wait before throwing an exception if no connection is available.  spring.datasource.tomcat.max-wait=10000  # Maximum no of active conn that can be allocated from this pool at the same time.  spring.datasource.tomcat.max-active=50  # Validate the connection before borrowing it from the pool.  spring.datasource.tomcat.test-on-borrow=true
  • 29. Continue…….  # Keep the connection alive if idle for a long time (needed in production)  spring.datasource.dbcp.test-while-idle=true  spring.datasource.dbcp.validation-query=SELECT 1  # Naming strategy  spring.jpa.hibernate.naming.strategy=org.hibernate.cfg.ImprovedNamingStrategy  # Hibernate ddl auto (create, create-drop, update): with "update" the database  # schema will be automatically updated accordingly to java entities found in  # the project  spring.jpa.hibernate.ddl-auto=update  # Show or not log for each sql query  spring.jpa.show-sql = true
  • 30. Load Custom Application Context package com.apps; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication @ImportResource("applicationContext.xml") public class MyAppApplication { public static void main(String[] args) { SpringApplication.run(MyAppApplication.class, args); } }
  • 31.
  • 32. Thank you  References  http://docs.spring.io/spring-boot/docs/2.0.x-SNAPSHOT/reference/html/  http://www.adeveloperdiary.com/java/spring-boot/an-introduction-to-spring- boot/  Assignment For you  Configure yourself  How to create jar for deployment on production server