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

Springboot

The document discusses various Spring MVC and REST annotations used for mapping web requests and binding request/response data in Spring Boot applications. It explains annotations like @RequestMapping, @GetMapping, @PostMapping, @PutMapping, @DeleteMapping, @PatchMapping, @RequestBody, @ResponseBody, @PathVariable, @RequestParam, @RequestHeader, and @RestController. Examples of usage are provided for each annotation. Additionally, it covers Spring Boot dependency management using Maven, advantages of the dependency management, inheriting from the starter parent, and configuring properties.

Uploaded by

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

Springboot

The document discusses various Spring MVC and REST annotations used for mapping web requests and binding request/response data in Spring Boot applications. It explains annotations like @RequestMapping, @GetMapping, @PostMapping, @PutMapping, @DeleteMapping, @PatchMapping, @RequestBody, @ResponseBody, @PathVariable, @RequestParam, @RequestHeader, and @RestController. Examples of usage are provided for each annotation. Additionally, it covers Spring Boot dependency management using Maven, advantages of the dependency management, inheriting from the starter parent, and configuring properties.

Uploaded by

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

-----------------------

Spring MVC and REST Annotations


@RequestMapping:
It is used to map the web requests.
It has many optional elements like consumes, header, method, name, params, path,
produces, and value.
We use it with the class as well as the method.

Example
@Controller
public class BooksController
{
@RequestMapping("/computer-science/books")
public String getAllBooks(Model model)
{
//application code
return "bookList";
}
@GetMapping: It maps the HTTP GET requests on the specific handler method. It is
used to create a web service endpoint that fetches It is used instead of using:
@RequestMapping(method = RequestMethod.GET)
@PostMapping: It maps the HTTP POST requests on the specific handler method. It is
used to create a web service endpoint that creates It is used instead of using:
@RequestMapping(method = RequestMethod.POST)
@PutMapping: It maps the HTTP PUT requests on the specific handler method. It is
used to create a web service endpoint that creates or updates It is used instead of
using: @RequestMapping(method = RequestMethod.PUT)
@DeleteMapping: It maps the HTTP DELETE requests on the specific handler method. It
is used to create a web service endpoint that deletes a resource. It is used
instead of using: @RequestMapping(method = RequestMethod.DELETE)
@PatchMapping: It maps the HTTP PATCH requests on the specific handler method. It
is used instead of using: @RequestMapping(method = RequestMethod.PATCH)
@RequestBody: It is used to bind HTTP request with an object in a method parameter.
Internally it uses HTTP MessageConverters to convert the body of the request. When
we annotate a method parameter with @RequestBody, the Spring framework binds the
incoming HTTP request body to that parameter.
@ResponseBody: It binds the method return value to the response body. It tells the
Spring Boot Framework to serialize a return an object into JSON and XML format.
@PathVariable: It is used to extract the values from the URI. It is most suitable
for the RESTful web service, where the URL contains a path variable. We can define
multiple @PathVariable in a method.
@RequestParam: It is used to extract the query parameters form the URL. It is also
known as a query parameter. It is most suitable for web applications. It can
specify default values if the query parameter is not present in the URL.
@RequestHeader: It is used to get the details about the HTTP request headers. We
use this annotation as a method parameter. The optional elements of the annotation
are name, required, value, defaultValue. For each detail in the header, we should
specify separate annotations. We can use it multiple time in a method
@RestController: It can be considered as a combination of @Controller and
@ResponseBody annotations. The @RestController annotation is itself annotated with
the @ResponseBody annotation. It eliminates the need for annotating each method
with @ResponseBody.
@RequestAttribute: It binds a method parameter to request attribute. It provides
convenient access to the request attributes from a controller method. With the help
of @RequestAttribute annotation, we can access objects that are populated on the
server-side.
---------------
Certainly! I'll include the endpoint URLs in the comments for each example:
@GetMapping:

java
Copy code
@RestController
@RequestMapping("/books")
public class BookController {

// Endpoint: GET /books/{id}


@GetMapping("/{id}")
public ResponseEntity<Book> getBookById(@PathVariable Long id) {
// Logic to retrieve a book by ID from a database or service
Book book = new Book(id, "Sample Book", "John Doe");
return ResponseEntity.ok(book);
}
}
@PostMapping:

java
Copy code
@RestController
@RequestMapping("/books")
public class BookController {

// Endpoint: POST /books


public ResponseEntity<Book> createBook(@RequestBody Book book) {
// Logic to save a book to a database or service
// Assuming the book object is sent in the request body
// ...
return ResponseEntity.status(HttpStatus.CREATED).body(book);
}
}
@PathVariable:

java
Copy code
@RestController
@RequestMapping("/books")
public class BookController {

// Endpoint: GET /books/{id}


@GetMapping("/{id}")
public ResponseEntity<Book> getBookById(@PathVariable Long id) {
// Logic to retrieve a book by ID from a database or service
Book book = new Book(id, "Sample Book", "John Doe");
return ResponseEntity.ok(book);
}
}
@RequestBody:

java
Copy code
@RestController
@RequestMapping("/books")
public class BookController {

// Endpoint: POST /books


public ResponseEntity<Book> createBook(@RequestBody Book book) {
// Logic to save a book to a database or service
// Assuming the book object is sent in the request body
// ...
return ResponseEntity.status(HttpStatus.CREATED).body(book);
}
}
@ResponseBody:

java
Copy code
@RestController
@RequestMapping("/books")
public class BookController {

// Endpoint: GET /books/{id}


@GetMapping("/{id}")
public ResponseEntity<Book> getBookById(@PathVariable Long id) {
// Logic to retrieve a book by ID from a database or service
Book book = new Book(id, "Sample Book", "John Doe");
return ResponseEntity.ok(book);
}
}
-----------------------
2) SB Depedency Managment (def,advantages,Maven DI,changing java version, adding
spring boot maven plugin,springboot without parent pom)
Spring Boot manages dependencies and configuration automatically. Each release of
Spring Boot provides a list of dependencies that it supports.
The list of dependencies is available as a part of the Bills of Materials (spring-
boot-dependencies) that can be used with Maven. So, we need not to specify the
version of the dependencies in our configuration.
Spring Boot manages itself. Spring Boot upgrades all dependencies automatically in
a consistent way when we update the Spring Boot version.

Advantages of Dependency Management


It provides the centralization of dependency information by specifying the Spring
Boot version in one place. It helps when we switch from one version to another.
It avoids mismatch of different versions of Spring Boot libraries.
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 default Java compiler version
UTF-8 source encoding
It inherits a Dependency Section from the spring-boot-dependency-pom. It manages
the version of common dependencies. It ignores the <version> tag for that
dependencies.
Dependencies, inherited from the spring-boot-dependencies POM
Sensible resource filtering
Sensible plugin configuration

Inheriting Starter Parent


The following spring-boot-starter-parent inherits automatically when we configure
the project.

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.2.BUILD-SNAPSHOT</version> <!-- lookup parent from repository -->
<relativePath/>
</parent>Note: In the above dependency, we have specified only the Spring Boot
version. If we want to add additional starters, simply remove the <version> tag.
Similarly, we can also override the individual dependency by overriding a property
in our project.For example, if we want to add another dependency with the same
artifact that we have injected already, inject that dependency again inside the
<properties> tag to override the previous one.

Changing the Java version


We can also change the Java version by using the <java.version> tag.
<properties>
<java.version>1.8</java.version>
</properties>

Adding Spring Boot Maven Plugin


We can also add Maven plugin in our pom.xml file. It wraps the project into an
executable jar file.
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

Spring Boot without Parent POM


If we don't want to use spring-boot starter-parent dependency, but still want to
take the advantage of the dependency management, we can use <scope> tag, as
follows:

Note: It does not maintain the plugin management.


<dependencyManagement>
<dependencies>
<dependency><!-- Import dependency management from Spring Boot -->
<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>
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>

3) SB Application Properties (Example, YAML Properties file,SB property Categories)


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.

The application.properties file allows us to run an application in a different


environment. In short, we can use the application.properties file to:

Configure the Spring Boot framework


define our application custom configuration properties
Example of application.properties
#configuring application name
spring.application.name = demoApplication
#configuring port
server.port = 8081
In the above example, we have configured the application name and port. The port
8081 denotes that the application runs on port 8081.
Note: The lines started with # are comments.

YAML Properties File

Spring Boot provides another file to configure the properties is called yml file.
The Yaml file works because the Snake YAML jar is present in the classpath. Instead
of using the application.properties file, we can also use the application.yml file,
but the Yml file should be present in the classpath.

Example of application.yml

spring:
application:
name: demoApplication
server:
port: 8081
In the above example, we have configured the application name and port. The port
8081 denotes that the application runs on port 8081.

Spring Boot Property Categories


There are sixteen categories of Spring Boot Property are as follows:

Core Properties
Cache Properties
Mail Properties
JSON Properties
Data Properties
Transaction Properties
Data Migration Properties
Integration Properties
Web Properties
Templating Properties
Server Properties
Security Properties
RSocket Properties
Actuator Properties
DevTools Properties
Testing Properties

4) SB Starters (third party starters,SB production Starters, SB Technical Starters)


Spring Boot provides a number of starters that allow us to add jars in the
classpath. Spring Boot built-in starters make development easier and rapid. Spring
Boot Starters are the dependency descriptors.
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.
The Spring Boot Framework provides the following application starters under the
org.springframework.boot group.

Name Description
spring-boot-starter-thymeleaf It is used to build MVC web applications using
Thymeleaf views.
spring-boot-starter-data-couchbase It is used for the Couchbase document-oriented
database and Spring Data Couchbase.
spring-boot-starter-artemis It is used for JMS messaging using Apache Artemis.
spring-boot-starter-web-services It is used for Spring Web Services.
spring-boot-starter-mail It is used to support Java Mail and Spring
Framework's email sending.
spring-boot-starter-data-redis It is used for Redis key-value data store with
Spring Data Redis and the Jedis client.
spring-boot-starter-web It is used for building the web application, including
RESTful applications using Spring MVC. It uses Tomcat as the default embedded
container.
spring-boot-starter-data-gemfire It is used to GemFire distributed data store
and Spring Data GemFire.
spring-boot-starter-activemq It is used in JMS messaging using Apache ActiveMQ.
spring-boot-starter-data-elasticsearch It is used in Elasticsearch search and
analytics engine and Spring Data Elasticsearch.
spring-boot-starter-integration It is used for Spring Integration.
spring-boot-starter-test It is used to test Spring Boot applications with
libraries, including JUnit, Hamcrest, and Mockito.
spring-boot-starter-jdbc It is used for JDBC with the Tomcat JDBC connection
pool.
spring-boot-starter-mobile It is used for building web applications using Spring
Mobile.
spring-boot-starter-validation It is used for Java Bean Validation with
Hibernate Validator.
spring-boot-starter-hateoas It is used to build a hypermedia-based RESTful web
application with Spring MVC and Spring HATEOAS.
spring-boot-starter-jersey It is used to build RESTful web applications using
JAX-RS and Jersey. An alternative to spring-boot-starter-web.
spring-boot-starter-data-neo4j It is used for the Neo4j graph database and
Spring Data Neo4j.
spring-boot-starter-data-ldap It is used for Spring Data LDAP.
spring-boot-starter-websocket It is used for building the WebSocket applications.
It uses Spring Framework's WebSocket support.
spring-boot-starter-aop It is used for aspect-oriented programming with Spring AOP
and AspectJ.
spring-boot-starter-amqp It is used for Spring AMQP and Rabbit MQ.
spring-boot-starter-data-cassandra It is used for Cassandra distributed database
and Spring Data Cassandra.
spring-boot-starter-social-facebook It is used for Spring Social Facebook.
spring-boot-starter-jta-atomikos It is used for JTA transactions using Atomikos.
spring-boot-starter-security It is used for Spring Security.
spring-boot-starter-mustache It is used for building MVC web applications using
Mustache views.
spring-boot-starter-data-jpa It is used for Spring Data JPA with Hibernate.
spring-boot-starter It is used for core starter, including auto-configuration
support, logging, and YAML.
spring-boot-starter-groovy-templates It is used for building MVC web
applications using Groovy Template views.
spring-boot-starter-freemarker It is used for building MVC web applications
using FreeMarker views.
spring-boot-starter-batch It is used for Spring Batch.
spring-boot-starter-social-linkedin It is used for Spring Social LinkedIn.
spring-boot-starter-cache It is used for Spring Framework's caching support.
spring-boot-starter-data-solr It is used for the Apache Solr search platform with
Spring Data Solr.
spring-boot-starter-data-mongodb It is used for MongoDB document-oriented
database and Spring Data MongoDB.
spring-boot-starter-jooq It is used for jOOQ to access SQL databases. An
alternative to spring-boot-starter-data-jpa or spring-boot-starter-jdbc.
spring-boot-starter-jta-narayana It is used for Spring Boot Narayana JTA
Starter.
spring-boot-starter-cloud-connectors It is used for Spring Cloud Connectors
that simplifies connecting to services in cloud platforms like Cloud Foundry and
Heroku.
spring-boot-starter-jta-bitronix It is used for JTA transactions using Bitronix.
spring-boot-starter-social-twitter It is used for Spring Social Twitter.
spring-boot-starter-data-rest It is used for exposing Spring Data repositories over
REST using Spring Data REST.
Spring Boot Production Starters
Name Description
spring-boot-starter-actuator It is used for Spring Boot's Actuator that provides
production-ready features to help you monitor and manage your application.
spring-boot-starter-remote-shell It is used for the CRaSH remote shell to
monitor and manage your application over SSH. Deprecated since 1.5.
Spring Boot Technical Starters
Name Description
spring-boot-starter-undertow It is used for Undertow as the embedded servlet
container. An alternative to spring-boot-starter-tomcat.
spring-boot-starter-jetty It is used for Jetty as the embedded servlet
container. An alternative to spring-boot-starter-tomcat.
spring-boot-starter-logging It is used for logging using Logback. Default logging
starter.
spring-boot-starter-tomcat It is used for Tomcat as the embedded servlet
container. Default servlet container starter used by spring-boot-starter-web.
spring-boot-starter-log4j2 It is used for Log4j2 for logging. An alternative to
spring-boot-starter-logging.

5) SB Startes Parent (SB Starter Parent Internal, SB starter without Parent)


The spring-boot-starter-parent is a project starter. It provides default
configurations for our applications. It is used internally by all dependencies. All
Spring Boot projects use spring-boot-starter-parent as a parent in pom.xml file.

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
</parent>
Parent Poms allow us to manage the following things for multiple child projects and
modules:
Configuration: It allows us to maintain consistency of Java Version and other
related properties.
Dependency Management: It controls the versions of dependencies to avoid conflict.
Source encoding
Default Java Version
Resource filtering
It also controls the default plugin configuration.
The spring-boot-starter-parent inherits dependency management from spring-boot-
dependencies. We only need to specify the Spring Boot version number. If there is a
requirement of the additional starter, we can safely omit the version number.

Spring Boot Starter Parent Internal


Spring Boot Starter Parent defines spring-boot-dependencies as a parent pom. It
inherits dependency management from spring-boot-dependencies.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.6.0.RELEASE</version>
<relativePath>../../spring-boot-dependencies</relativePath>
</parent>
Default Parent Pom

<properties>
<java.version>1.8</java.version>
<resource.delimiter>@</resource.delimiter>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
</properties>
The properties section defines the application default values. The default Java
version is 1.8. We can also override Java version by specifying a property
<java.version>1.8</java.version> in the project pom. The parent pom also contains
the few other settings related to encoding and source. The Spring Boot framework
uses these defaults in case, if we have not defined in the application.properties
file.

Spring Boot Dependencies


The spring-boot-starter-parent dependency inherit from the spring-boot-
dependencies, it shares all these characteristics as well. Hence the Spring Boot
manages the list of the dependencies as the part of the dependency management.
Spring Boot Starter without Parent
In some cases, we need not to inherit spring-boot-starter-parent in the pom.xml
file. To handle such use cases, Spring Boot provides the flexibility to still use
the dependency management without inheriting the spring-boot-starter-parent.

<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.1.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
In the above code, we can see that we have used <scope> tag for this. It is useful
when we want to use different version for a certain dependency.

6) SB Starter Web ( SB Embedded Web Server,using another embedded web server,SB


starter web vs SB Starter tomcat)
two important features of spring-boot-starter-web:
1. It is compatible for web development
2. Auto configuration
If we want to develop a web application, we need to add the following dependency in
pom.xml file:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.2.2.RELEASE</version>
</dependency>
Starter of Spring web uses Spring MVC, REST and Tomcat as a default embedded
server. The single spring-boot-starter-web dependency transitively pulls in all
dependencies related to web development. It also reduces the build dependency
count. The spring-boot-starter-web transitively depends on the following:

org.springframework.boot:spring-boot-starter
org.springframework.boot:spring-boot-starter-tomcat
org.springframework.boot:spring-boot-starter-validation
com.fasterxml.jackson.core:jackson-databind
org.springframework:spring-web
org.springframework:spring-webmvc
By default, the spring-boot-starter-web contains the following tomcat server
dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>2.0.0.RELEASE</version>
<scope>compile</scope>
</dependency>
The spring-boot-starter-web auto-configures the following things that are required
for the web development:

Dispatcher Servlet
Error Page
Web JARs for managing the static dependencies
Embedded servlet container
Spring Boot Embedded Web Server
Each Spring Boot application includes an embedded server. Embedded server is
embedded as a part of deployable application. The advantage of embedded server is,
we do not require pre-installed server in the environment. With Spring Boot,
default embedded server is Tomcat. Spring Boot also supports another two embedded
servers:

Jetty Server
Undertow Server
Using another embedded web server
For servlet stack applications, the spring-boot-starter-web includes Tomcat by
including spring-boot-starter-tomcat, but we can use spring-boot-starter-jetty or
spring-boot-starter-undertow instead.

For reactive stack applications, the spring-boot-starter-webflux includes Reactor


Netty by including spring-boot-starter-reactor-netty, but we can use spring-boot-
starter-tomcat, spring-boot-starter-jetty, or spring-boot-starter-undertow instead.

Jetty Server
The Spring Boot also supports an embedded server called Jetty Server. It is an HTTP
server and Servlet container that has the capability of serving static and dynamic
content. It is used when machine to machine communication is required.

If we want to add the Jetty server in the application, we need to add the spring-
boot-starter-jetty dependency in our pom.xml file.
ADVERTISEMENT

Remember: While using Jetty server in the application, make sure that the default
Tomcat server is excluded from the spring-boot-starter-web. It avoids the conflict
between servers.

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
We can also customize the behavior of the Jetty server by using the
application.properties file.

Undertow Server
Spring Boot provides another server called Undertow. It is also an embedded web
server like Jetty. It is written in Java and manage and sponsored by JBoss. The
main advantages of Undertow server are:

Supports HTTP/2
HTTP upgrade support
Websocket Support
Provides support for Servlet 4.0
Flexible
Embeddable
Remember: While using Undertow server in the application, make sure that the
default Tomcat server is excluded from the spring-boot-starter-web. It avoids the
conflict between servers.

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>
We can also customize the behavior of the Undertow server by using the
application.properties file.

spring-boot-starter-web vs. spring-boot-starter-tomcat


The spring-boot-starter-web contains the spring web dependencies that includes
spring-boot-starter-tomcat. The spring-boot-starter-web contains the following:

spring-boot-starter
jackson
spring-core
spring-mvc
spring-boot-starter-tomcat
While the spring-boot-starter-tomcat contains everything related to Tomcat server.
core
el
logging
websocket
The starter-tomcat has the following dependencies:

<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>8.5.23</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-el</artifactId>
<version>8.5.23</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-websocket</artifactId>
<version>8.5.23</version>
<scope>compile</scope>
</dependency>
We can also use spring-mvc without using the embedded Tomcat server. If we want to
do so, we need to exclude the Tomcat server by using the <exclusion> tag, as shown
in the following code.

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>

7) SB Started Data JPA (features, spring data repository, SB starter data


jpa,Hibernate vs JPA, SB JPA Example)

8) SB Starter Actuator (features, enabling SB actuator, SB Actuator Endpoints, SB


actuator properties, SB actuator example

9) SB Starter Test (example)

10) SB DevTools (Features,Using a Trigger File,Example)

11) Multi Module Project (Parent POM,Why we need multi-module project,

Child module-ear, war, and jar.,Maven child projects/ modules,Multi-Module


Project Directory Structure,

Spring Boot Multi-Module Project Example,POM Aggregator (Parent POM)

12) SB Packaging (WAR, JAR, EAR with exaples)

13)SB Auto-Configuration (Need of auto-configuration, Disable Auto-configuration


Classes,

Spring Boot Auto-configuration Example

*******
SB hello-world example

Project Deployement using Tomcat

Spring AOP

Spring Boot AOP

AOP before Advice

AOP after Advice

AOP Around Advice

AOP Returning Advice

AOP Throwing

Spring Boot Databases


Spring Boot JPA

Spring Boot JDBC

SB JDBC Example

SB H2 Database

SB CRUD operations

SB Caching

SB Caching (cache abstraction,caching, why should we use the cache, what data
should be cached,

types of caching,cache vs buffer,SB cache annotations,SB Cache


dependecy,Example of SB Cache)

SB Cache Provider (Caching Auto-configuration,generic cache,.......)

SB EhCaching (Features, Usage Patterns, Cache-aside,EhCaching Storage Tiers,


Configuring EhCache)

Run SB Application

SB Change Port

SB Rest Example

SB RESTful Web Services


1) Introduction to RESTful Web Services

methods of HTTP are:


GET: It reads a resource.
PUT: It updates an existing resource.
POST: It creates a new resource.
DELETE: It deletes the resource.

standard status code:


404: RESOURCE NOT FOUND
200: SUCCESS
201: CREATED
401: UNAUTHORIZED
500: SERVER ERROR

RESTful Service Constraints

There must be a service producer and service consumer.

The service is stateless.

The service result must be cacheable.

The interface is uniform and exposing resources.

The service should assume a layered architecture.

Advantages of RESTful web services


2) Initializing a RESTful Web Services Project with Spring Boot

creating a hello world service

Enhancing the Hello World Service to Return a Bean

3) Spring Boot Auto Configuration and Dispatcher Servlet

What is dispatcher servlet?

Who is configuring dispatcher servlet?

What does dispatcher servlet do?

Spring Boot Auto Configuration?

4) Enhancing the Hello World Service with a Path Variable

5) Implementing the POST Method to create User Resource

6) Implementing Exception Handling- 404 Resource Not Found

7) Implementing Generic Exception Handling for all Resources

8) Implementing DELETE Method to Delete a User Resource

9) Implementing Validations for RESTful Services

10) Implementing HATEOAS for RESTful Services

11) Internationalization of RESTful Services

12) Content Negotiation Implementing Support for XML

13) Configuring Auto Generation of Swagger Documentation & Introduction to Swagger


Documentation Format

14) Enhancing Swagger Documentation with Custom Annotations

15) Monitoring APIs with Spring Boot Actuator

16) Implementing Static Filtering for RESTful Services

17) Implementing Dynamic Filtering for RESTful Services

18) Versioning RESTful Web Services-Basic Approach With URIs

19) Implementing Basic Authentication with Spring Security

20) Connecting RESTful Services to JPA

21) Updating GET Methods on User Resource to Use JPA

22) Updating POST and DELETE methods on UserResource to use JPA

23) Creating Post Entity and Many to One Relationship with User Entity

24) Implementing a GET service to retrieve all Posts of a User


25) Implementing POST Service to Create a Post for a User

26) Richardson Maturity Model

27) RESTful Web Services Best Practice

************************************************************
https://javahelps.com/how-to-add-mysql-jdbc-driver-to-eclipse
https://ibytecode.com/blog/jdbc-mysql-connection-tutorial/
https://www.researchgate.net/publication/
324454006_Java_Database_Connectivity_Using_MySQL_A_Tutorial

You might also like