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.


Resource Oriented Architecture

REST follows resource oriented architecture as opposed to the popular service oriented architecture followed by SOAP web services.

Resource-Oriented Architecture has four important concepts:

  • Resources,

  • their names (URIs),

  • their representations and

  • the links between them.


A Quick Introduction to Java 8

Java is one of the most popular programming languages. However, recently many other programming languages have come and some of them even running on top of the Java Virtual Machine (JVM). Many of these languages support newer programming practices like functional programming and comes with a bunch of out of the box functionalities that abstract away most of the low level details from the programmer.


Collection Framework Related Improvements in Java 8

Java 8 has has made some improvements in collections framework such as a new forEach loop, better type inference etc. We will list out those features here.


The forEach method

The default forEach method of the Iterable interface performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception. 

Signature of the methiod is: void forEach(Consumer<? super T> action)


Search the Web

Custom Search

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