spring4
spring4
Spring Boot Annotations is a form of metadata that provides data about a program. In
other words, annotations are used to provide supplemental information about a
program. It is not a part of the application that we develop. It does not have a direct
effect on the operation of the code they annotate. It does not change the action of
the compiled program.
@Service: It is also used at class level. It tells the Spring that class contains
the business logic.
We only need to write a library name with specifying the version. It is helpful in
multi-module projects.
Maven Dependency Management System
The Maven project inherits the following features from spring-boot-starter-
parent:
The above dependency does not allow overriding. To achieve the overriding,
we need to add an entry inside the <dependencyManagement> tag of our
project before the spring-boot-dependencies entry.
For example, to upgrade another spring-data-releasetrain, add the following
dependency in the pom.xml file.
<dependencyManagement>
<dependencies>
<!--Override Spring Data release train-->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-releasetrain</artifactId>
<version>Fowler-SR2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.2.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Spring Boot Application Properties
Spring Boot Framework comes with a built-in mechanism for application
configuration using a file called application.properties. It is located inside
the src/main/resources folder, as shown in the following figure.
Spring Boot provides various properties that can be configured in
the application.properties file. The properties have default values. We can set a
property(s) for the Spring Boot application. Spring Boot also allows us to define our
own property if required.
In the above example, we have configured the application name and port.
The port 8081 denotes that the application runs on port 8081.
In the Spring Boot Framework, all the starters follow a similar naming pattern: spring-
boot-starter-*, where * denotes a particular type of application. For example, if we
want to use Spring and JPA for database access, we need to include the spring-boot-
starter-data-jpa dependency in our pom.xml file of the project.
Third-Party Starters
We can also include third party starters in our project. But we do not use spring-
boot-starter for including third party dependency. The spring-boot-starter is reserved
for official Spring Boot artifacts. The third-party starter starts with the name of the
project. For example, the third-party project name is abc, then the dependency name
will be abc-spring-boot-starter.