© Marten Deinum 2018
Marten DeinumSpring Boot 2 Recipeshttps://doi.org/10.1007/978-1-4842-3963-6_2

2. Spring Boot—Basics

Marten Deinum1 
(1)
Meppel, Drenthe, The Netherlands
 

In this chapter we will take a look at the basic features of Spring Boot.

Note

To get a starting point, use the Spring Initializr to create a project. No additional dependencies are required, just a Spring Boot project.

2.1 Configure a Bean

Problem

You want Spring Boot to use your class as a bean.

Solution

Depending on your needs, you can either leverage @ComponentScan to automatically detect your class and have an instance created; use it together with @Autowired and @Value to get dependencies or properties injected; or you can use a method annotated with @Bean to have more control ...

Get Spring Boot 2 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.