Spring Boot Dependency Management Highlights

Bill of Materials

Getting started with Spring Boot

To understand and to work with Spring Boot better, it is good to have a decent knowledge of Java, Spring framework and one of Maven/Gradle. Note that Spring Boot is just a convenient way to do Spring.


Your First Spring Boot Web Application

In the previous example, we created a simple standalone application using the dependency spring-boot-starter. In this example, we will convert it into a simple web application with very minimal changes.

Introduction to Spring Boot

Spring Boot can be considered as a new way to create Spring applications with ease. With Spring Boot, you can create standalone applications with an embedded server and you can "just run" them. For instance a web application can be run from your desktop similar to a desktop application.

Spring boot home page @ describe itself as follows:

Upcoming Spring Notes

Here I will list out upcoming notes or notes sections (books) on Spring.

  • Aspect Oriented Programming

  • Testing with Spring

  • Transactions with Spring

  • Spring and Data

  • Spring Boot Essentials (In progress)

  • Spring MVC Essentials (In progress)



Initialization and Destruction Code for a Spring Bean

There are different ways to executing some code during initialization and destruction of a bean. We could do that using InitializingBean interface, but there are better approaches using annotations.

We will see two of such approaches here:

  1. Using initMethod and destroyMethod attributes of the @Bean annotation

    • Advantage: We do not need source code access to component classes.

    • Limitation: We cannot specify methods that accept any parameters

Bean Scopes in Spring with Example

Beans in Spring can be either singletons or prototypes. Singleton means that only one instance of the bean will be maintained by the Spring and will be returned every time you call the getBean() method. If you set the scope to prototype, then a new bean will be created every time you call the getBean() method.

The default is singleton. In Java configuration, you can specify that a bean scope is prototype by specifying @Scope("prototype") over the bean definition.


Additional Exercises for Mastering Spring Framework 4 Essentials

These are additional exercises you can try out once after learning and practicing all the previous exercises in this section. There will be also hints to make things easier.

  1. Provide examples for autowire for type and autowire by construtcor following the note

Configuring Spring 4 Applications

You can configure a Spring application entirely using xml configuration or using a Java configuration. XML configuration was the original configuration approach in Spring. Spring 2.0, which came in 2006, simplified the XML configurations.Spring 2.5, which came in 2007, introduced annotation configurations. Spring 3.2, which came in 2012, introduced Java configuration. You can use annotations to do most of the things along with xml or java configuration. However, you will mostly not see both xml configuration or Java configuration used together. 

Important JAX-RS Annotations

Below JAX-RS annotations aid in mapping a resource class (a POJO) as a web resource:

  • @Path

    • specifies the relative path for a resource class or method.

  • @GET, @PUT, @POST, @DELETE and @HEAD

    • specify the HTTP request type of a resource.

  • @Produces

    • specifies the response Internet media types (used for content negotiation).

  • @Consumes

    • specifies the accepted request Internet media types.



Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within!!!