0% found this document useful (0 votes)
1K views2 pages

Spring Boot 2 Cheat Sheet

Spring Boot is a framework for creating stand-alone, production-grade Spring based Applications that can be "just run". It takes an opinionated view of the Spring platform and third-party libraries so that new and existing Spring developers can quickly get started with minimal configuration. Spring Boot applications can be started using java -jar or an embedded HTTP server and provides production-ready features such as health checks, metrics, and externalized configuration.

Uploaded by

Laszlo Kamler
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views2 pages

Spring Boot 2 Cheat Sheet

Spring Boot is a framework for creating stand-alone, production-grade Spring based Applications that can be "just run". It takes an opinionated view of the Spring platform and third-party libraries so that new and existing Spring developers can quickly get started with minimal configuration. Spring Boot applications can be started using java -jar or an embedded HTTP server and provides production-ready features such as health checks, metrics, and externalized configuration.

Uploaded by

Laszlo Kamler
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

SPRING BOOT 2 CHEAT SHEET

Spring Boot - Date :

Don't use the **default** package. Prefer using


the Java convention *com.example.project*
• Built on top of a lot of Spring Projects
(https://spring.io)
• Opinionated con�guration
• Wide ecosystem com
• Start a project faster with no con�guration + example
| + project
| | - MyApp.java
| | |
| | + player
• Bootstrap class SpringApplication | | | - Player.java
• Default logger (@see spring-jcl) | | | - PlayerService.java
• FailureAnalyzers : friendly failure report
• Application Events on Listeners
• Choose the right ApplicationContext
• Accessing application arguments Properties �les in folder src/main/resources/ are loaded
• Control application exit code automatically

• : **/application*.yml or
**/application*.yaml
• : **/application*.properties
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-
parent</artifactId> • Enabled by @SpringBootApplication or
<version>2.1.0.RELEASE</version> @EnableAutoConfiguration
</parent>
• Spring Boot scans all libs on the classpath and auto-
<dependencies> con�gures them ( )
<dependency>
Display Spring Boot Autocon�gure report
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency> java -jar myapp.jar --debug
</dependencies>
Disabling an auto-con�guration class with Java conf
@SpringBootApplication
public class MyApp { @EnableAutoConfiguration(exclude=
{DataSourceAutoConfiguration.class})
public static void main(String[] args) {
SpringApplication.run(MyApp.class, args); Disabling an auto-con�guration class with properties
}
spring.autoconfigure.exclude= \
}
org.springframework.boot.autoconfigure.XXXX

groupe-sii.github.io/cheat-sheets www.groupe-sii.com blog.groupe-sii.com

 
SPRING BOOT 2 CHEAT SHEET

Maven O�cial starters : spring-boot-starter-*

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId> Web applications using Spring
<artifactId>spring-boot-maven- MVC (Tomcat embedded)
plugin</artifactId>
</plugin> Spring test using JUnit, Hamcrest
</plugins> and Mockito
</build>
Secured services with Spring
Gradle Security
WebFlux applications using Spring
plugins { Framework’s Reactive Web
id 'org.springframework.boot' version
'2.1.0.RELEASE' WebSocket applications using
} Spring Framework’s WebSocket
Con�gured resources to use
Spring Data JDBC
Production ready features threw HTTP or JMX Con�gured resources to use
Spring Data JPA with Hibernate
<dependency>
<groupId>org.springframework.boot</groupId> Web applications using Spring
<artifactId>spring-boot-starter- Data repositories over REST
actuator</artifactId>
Production ready features using
</dependency>
Spring's Actuator (monitor and
manage)

Standalone

java -jar target/myapplication-0.0.1-SNAPSHOT.jar Using Jetty over the default Tomcat


Using Log4j2 for logging over the
Standalone with remote debug
default Logback
java -Xdebug \ Using Undertow over the default
-Xrunjdwp:server=y,transport=dt_socket\ Tomcat
,address=8000,suspend=n -jar target/myapplication-
0.0.1-SNAPSHOT.jar

Maven
• https://spring.io/guides
mvn spring-boot:run • https://spring.io/projects/spring-framework
• Spring Boot documentation
Gradle • Spring Core cheat sheet

gradle bootRun

groupe-sii.github.io/cheat-sheets www.groupe-sii.com blog.groupe-sii.com

You might also like