0% found this document useful (0 votes)
28 views

Spring 120 Boot Initilizr

Uploaded by

HamidImihi
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Spring 120 Boot Initilizr

Uploaded by

HamidImihi
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

SPRING BOOT INITIALIZR

Septembre 2021
*Réussir la transformation. Ensemble.

Zinoun Badr Eddine


Delivering Transformation. Together.*
SPRING BOOT
Spring remade simple

http://start.spring.io/

2
Induced to evolve ?
STS : Spring Starter Project

STS : Spring IDE Tools Suite provides the following wizards :

Note : no test, log4j, jpa

3
Spring Starter Project

Note :
no check box for test,
or log4j ?

=> spring-test is
automatically added.

=> by default you get


logback

4
Installing
Generated Maven Project =>

5
Setup Preferred way
Maven Project with BOM (no pom parent anymore)

6
Other Spring-Boot Starters

7
Spring Boot Starters
Make your choice ! You can simply hit ctrl-space in the POM editor and type ''spring-boot-
starter'' for a complete list.
 spring-boot-starter  spring-boot-starter-jersey
 spring-boot-starter-actuator  spring-boot-starter-jta-atomikos
 spring-boot-starter-amqp  spring-boot-starter-jta-bitronix
 spring-boot-starter-aop  spring-boot-starter-mail
 spring-boot-starter-batch  spring-boot-starter-mobile
 spring-boot-starter-cloud-connectors  spring-boot-starter-mustache
 spring-boot-starter-data-elasticsearch  spring-boot-starter-redis
 spring-boot-starter-data-gemfire  spring-boot-starter-security
 spring-boot-starter-data-jpa  spring-boot-starter-social-facebook
 spring-boot-starter-data-mongodb  spring-boot-starter-social-linkedin
 spring-boot-starter-data-rest  spring-boot-starter-social-twitter
 spring-boot-starter-data-solr  spring-boot-starter-test
 spring-boot-starter-freemarker  spring-boot-starter-thymeleaf
 spring-boot-starter-groovy-templates  spring-boot-starter-velocity
 spring-boot-starter-hateoas  spring-boot-starter-web
 spring-boot-starter-hornetq  spring-boot-starter-websocket
 spring-boot-starter-integration  spring-boot-starter-ws
 spring-boot-starter-jdbc
8
SPRING BOOT CONFIGURATION
STARTER

Each starter is just a dependency

here example with jpa =>

9
Spring Tools Suite STS
Help

Demo/Exercize

If you try to use @Entity on a project without JPA in the classpath,


Spring-Boot will propose it to you … the spring-boot-starter-data-jpa

And STS would also add Hibernate and many other jars !

Eclipse Quick access : Ctrl + 3


on AZERTY : Ctrl+Shift+3
10
BOOT INNER MECHANICS

11 Nom de la présentation
SPRING BOOT CONFIGURATION
EMBEDDED DB

Boot checks that your config is consistent

Embedded DB conf
 if you define a dep with data-jpa you need a DB:

12
SPRING BOOT CONFIGURATION
OR A FULL EXTERNAL DB =>

Real DB conf : the starter JPA requires either the driver of an embedded DB
or the DB driver + the following properties ( user + pwd+ db-url ) from
application.properties

13
Spring Boot Starters

Why is Spring-Boot easier than just Spring ?

 Global consistent classpath with no effort


 You make macro choices => Spring manages the details
 The configuration part is automatic
 the pom.xml could be customized if needed !
 With Spring properties and your Beans you can override the configuration

14
Induced to evolve ?
STS Starter Project

Logback logging is the best


A successor to the popular log4j project, picking up where log4j leaves off.

url :

You can still rely on log4J if you want with : spring-boot-starter-log4j

Slf4j is always used as a front

15
Spring BOOT
LogBack loggers

Turning on LOGBACK logs

16
Spring BOOT
LogBack loggers

Second solution to LOGBACK settings


 add properties inside application.properties

17
AUTO-CONFIGURATION-REPORT

Turn on the logging level in DEBUG for the class:


v1+
org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingInitializer

v2+

We see all the auto-configuration (around 90 test classes !)


launched /tested by Spring-Boot

18
AUTO-CONFIGURATION-REPORT

In Spring-Boot 2.1.4
 Just add the properties debug= true in your application.propert

19
BOOT MAVEN
Boot centralized params for choosing : JDK version and encoding
maven.compiler.source
maven.compiler.target

20
Default Maven behavior
JDK and source file encoding

The Maven compiler could be accessed directly and customized :

Or you can set specific properties to achieve the same result :

21
Spring Boot factorized JDK and encoding properties
Boot as a maven parent

In an Initializr Boot project, your pom has a parent :

java.version is NOT a default Maven property • this default value should be overriden
to use a JDK8 for example
• project.build.sourceEncoding does not
need any override if you set your
eclipse editor to UTF-8 (default is cp-
in the parent 1252)

22
Spring Boot factorized JDK and encoding properties
no Boot parent

If your prefer not to have a boot parent and use the dep Management
strategy (as below), you loose your boot parent and so you also loose the
the <java.version> factorized property.

In that case, you should set those properties as in usual non-boot maven
properties :
 for example using the standard maven compiler properties :

23

You might also like