[Link]@gmail.
com
Introduction to SpringBoot
(Spring Framework @AutoConfigure...)
This document:
[Link]
[Link]
Google Rank #1 “springboot”
[Link]
no Wikipedia?
A Sub-Project (among 100)
of SpringFramework
Spring with Convention Over Configuration
Easier
Smaller
Just work
SpringBoot = a Sub-Project of
SpringFramework
“What is SpringBoot ? “
=
“What is SpringFramework ?”
+
“What is in SpringBoot & not in SpringFramework ?”
[Link]
“SpringFramework” Wikipedia
Wikipedia Extract
The Spring Framework is an application framework
and inversion of control container
for the Java platform.
can be used by any Java application ..
.. extensions for web applications.
… popular in the Java community .. alternative EJB.
open source
History & Authors
● framework for J2EE-* libs in <xml>…
● Developped by Rod Johnson
& Juergen Hoeller
● in ~ 2003
● SpringBoot is @Automagic without </xml>
● From Dave Sayer & Phil Webb
● In ~ 2014
on
pti
do
t
oo
,a
gB
ds
2014
loa rin
wn Sp
[Link]
Do
on
ati
g 4 ur
rin nfig
2013
Sp Co
=@
s ..
on can.
g 3 ati
rin not ntS
2009
Sp An pone
= @ om
@C
Spring History
e
.5 pac
g 2 mes
rin
Sp L Na
2007
1M
XM
0k
40
BC
JD
1.0 ring te
2004
Sp erna
Hib P
AO
..
or k
ew
r am
gF . 9
rin e 0 e
Sp leas ourc
2003
Re en S
Op .. .
EE
J2
Rod Johnson
ert rk
xp wo
:E me
ok Fra 1)
Bo
OC e2
k L fac
2002
31 inter
(=
Game of the Name
(French Translation)
● Spring = “ressort”, “printemps”, “renouveau”
● After the cold winter of ugly EJB specs 1.0, 2.0, …
● Framework = “Cadre de Travail”
● = Way of working, proposed / imposed by library
● Boot = “démarrage”
● = your app is a 1 line main() with @magic
[Link]
Amazing Starter
Amazing
Tutorials & Doc
[Link]
1/ Download + 2/ Mvn + 3/ Eclipse
[Link]
1/ Download + 2/ Mvn + 3/ Eclipse
1/ Download + 2/ Mvn + 3/ Eclipse
4/ Run IT …
Just Another Hello World App ?
5/ Junit Test It !!
5/ Junit OK
6/ Easy packaging to launch main
… java -jar
Small all-in-one target/jar
6.3 M “only”
“Hello World” ok
But what is Really SpringBoot?
What's Next ?
An “Ascii Art Banner” Printer ?
[Link]
src/main/resources/
[Link]
“Hello” that contains the “World” jars
mvn dependency:tree
Same as in eclipse, using command line
Dependencies …
(excluding <scope>test<scope>)
Almost a WebApp (add 4 lines)...
Add Web page
resources/static/[Link]
Restart... your Web Application
running in 2 seconds
[Link]
… “Just work”
Details HTTP Protocol,Header
Add Dynamic Page
(jsp, velocity, thymeleaf, ...)
For old-school html-1.0
… only for poor PHP lost guies
Now in 2016 … Using html-5
… You need/should/must NOT do like that
Dynamic Java Page = MVC
[Link]
Spring-mvc Spring-mvc
filter dispatcher C = Controller
(cookie,security...) (by URL mapping)
M = Model
Spring-mvc “viewResolver”
WEB-INF/jsp/[Link]
V = View
WEB-INF = internal
..not public from outside
(no /[Link] URL)
Springboot for Dynamic Pages
Dynamic Page JUST Work
Poor PHP
Jalous Developpers
Type-Safe, Multi-Thread-Safe, Compiled, Performant,
Garbage-Collected, I am looking at you
JRE Portable, Debuggable, Monitorable, Bytecode Agent
Object-Oriented, Aspect-Oriented, Annotations Processed,
Functional Lambda,
Multi-JDK-Langages (Groovy,Scala,Kotling,..)
Rich Libs, Rich Ecosystem, Huge Community...
Don't say “PHP” Again
Once Upon a Time … Html5
JavaScript, Json, DOM, Ajax,
WebSocket, WebComponent, ...
Your web-site = 1 web-page = 1 APPLICATION
running on the browser
Using client-side CPU, GraphicCard,Cookies,WebStorage,..
You don't explicitely “install” an app,
you just see 1 “html/css” page + also downloaded 1 “[Link]”
Then you GET+POST Rest/Json data … and RealTime WS
Web App = (static) Html + Rest API
Static resources part
html, css, js, png, …
(1=Frontend, LoadBalancer)
Get static 1 2 3
html, css, [Link]
(download + cache)
Dynamic part
2=Backend...
business logic...
Cookies, Rest/Json Request GET,POST,PUT...
LocalStorage 3-Tiers Architecture
(sometimes, 1=2)
Rest/Json Response
WebSocket PUSH (RealTime ..exemple : chat)
Springboot = for Backend Devs
De facto tools= nodejs gulp+npm+bower... De facto tools (in JVM world)
(in JS world … also GWT,and others) springboot + maven + ...
1 2 3
Pure Web-Designer
Front-end Developper Back-end Developper
DBA, BigData-Analyst
Full-Stack Developper
Add REST/Json Web API
Using “Built-in” Bind to JAX-RS
spring-web-mvc standard
specific annotations standard annotations
@RequestMapping @Path @GET
@RequestBody ... @ ...
Using Spring-web-mvc
@RestController
@RequestMapping
Run REST/Json Web API
AutoReload & LiveReload
● AutoReload :
change your spring app
=> server auto restart (partial)
For fast developer experience
… prefer gulp …
● LiveReload: in particular if in Eclipse <=2016
change Html/Css/Typescript/...
=> client Web Browser auto refresh!!
<script>... :35729/ [Link]</script>
Still Deploy with “java -jar …. “
now 14M jar ...
java -jar … = Web App !
Dependencies Added
for spring-boot-start-web
Tomcat
embedded .jar
JAR > WAR
ClassLoader in springboot
can zip nested jar
RIP WebLogic / WebSphere /
GlassFish / WildFly / ...
Comparatively …
1 day to install the server
1 week to read JEE doc
1 month to read specific doc
1 month to struggle in /console & wlst
5 minutes to stop-restart a server
1 minute to rebuild
3 minutes to redeploy a war 2 Seconds
(+ 5mn : often restart anyway ..) to build / start / hot-
+ 1 minute remote debugging restart
0 Value added either in Eclipse
-10000 $ on your bank account Or java -jar
as Josh Long said in one of his talks
in the Spring IO
“it is better to make Jar, not War”.
Josh Long
the Spring Developer Advocate at Pivotal
@starbuxman
Amazing Conferences
example at Devoxx
#MakeJarNotWar @starbuxman
[Link]
2000 “make jar not war”
App Server
Embedded Server > Deployed War
Your paid $$$ webserver
Your classes
Embedded
tomcat
Your JAR Your WAR
packaging + classes
also contains Your WAR
embedded tomcat is deployed
into a WebServer
Historical Reasons
1 Server = 1 JVM – Several Apps
1 Server = 1 JVM process
… serves several Apps
JSP Web Portal calling other JSP ?
Web $$$ Expensive => use 1 server for many apps
Limited RAM (1-8 G) …
jvm overhead = 100M
=> share RAM on workstations
Problems:
bad isolation …
OutOfMemory Error App1 => also crash App2,App3...
Redeploy / Restart App1 => stop all App2,App3...
“Hello Web World” ok
Only yet another Web Framework ?
What's Next ?
Springboot Almost contains
a Jdbc Database App
(add 4 lines)...
spring-jdbc
Run Jdbc App
Springboot built-in supports JTA
@Transactional
@Transactional JUST Works
Almost a Rich JPA-Data Db App
(add 4 lines)...
Code using JPA CRUD
findOne,findBy,save()...
Repository …
autoconfigured at runtime
By naming convention .. Equivalent to:
“Select * from EMPLOYEE where email=?”
Extends JpaRepository
built-in CRUD …
findAll, by Page, save, delete...
(no update, use Setters)
@Entity, @Id (optionnal @Version)
@OneToMany, @ManyToOne
Database table “EMPLOYEE” Database table “DEPARTMENT”
(id (PK), version, first_name, last_name, …. (id (PK), name)
department_id (FK [Link])
Springboot @JPA configuration
springboot dark magic
not even 1 line .. all optional !!!
Useless equivalent
2 implicit lines
Optional
for debug (see next)
Springboot hibernate… “JUST work”
CRUD …
select * from EMPLOYEE where …
insert into EMPLOYEE (..) values (..)
When/How/Where are my
“create Table ()” ???
Tables are created/updated at startup
Detected H2 Database SQL langage
Also create PK/FK indexes
How??
Which call JPA..
→ Hibernate...
→ JDBC
Call springboot-data
JpaRepository
You code
calls a generated
Proxy..
This was “only” 10%
of springboot and spring-*
5% Web 5% JPA
90% Remains … & More in progress
Springboot-* page1/5
Springboot-* page 2/5
NoSQL Databases:
Key-Values,
Columns,
Graphs
FullText
Springboot-* page 3/5
Cloud
=
For DataCenters
(10 000 PCs..)
discovery+failover
+load-balancer+
...
Springboot-* page 4/5
Asynchronous
Messages Bus
Springboot-* page 5/5
Input-Processing-Output
for files/messages/events
Mail
Monitoring
Statistics,
Management
Springboot : Lot of Cloud ...
Because it is used by HUUUGE companies
to run their business
DataCenters
- Alibaba
- Amazon
- Netflix
- Linked-In
- Twitter
- ...
Play This Video !!!
AngularJS + Springboot
In Jhipster … you have 100% springboot on server-side
… with Code Generator
And also Hipe code on client-side : Html / Css + AngularJS + ..
Java is Hipe
Make Jar nor WAR – NO PHP
NO NodeJS on server
20 years of Java
Just The Beginning
Its HIPE ...because of springboot
& open-source & java community
Conclusion
Conclusion
Only a very short introduction to spring-boot
This document:
[Link]
[Link]