/learn-spring-boot-guru

This a sample based on springframeworkguru.

Primary LanguageJava

learn-spring-boot-guru

This source is based at the course of springframework.guru using Java 10 and Gradle !

Branch 1-add-entities

In this branch, it was added new models (entities): Author, Book and Publisher, also it was created one class named IdEntity who has the Id attribute, its assessors and the implementation to equals and hashcode.

It was created in three repositories to manipulate data to the models previously created. How I'm using H2 as the database (in memory ), I created a bootstrap class to populate data when the application is starting.

Finally, to get access from the H2 database console, it was put spring.h2.console.enabled=true in the configurations.

Branch 2-mvc-controllers

In this branch, it was added to the first steps using Thymeleaf to create the first HTML pages: books and authors. To manage this pages, it was created the controllers named BookController and AuthorController. The controllers are classes annotated with @Controller and each controller has a method annotated with @RequestMapping where is specified the name of the action called by request. These methods populate attributes who are sent to in the HTML pages.

Branch 3-dependency-injection

In this branch, it was added some examples of how to use DI (Dependency Injection). It was shown three ways to do this:

  • HelloControllerProperty: using the annotation @Autowired on the property.
  • HelloControllerSetter: using the annotation @Autowired in the setter.
  • HelloControllerConstructor: the annotation @Autowired is optional if the constructor is used. It is the recommended way.

All the controller are annotated with @Controller, where each controller has a @Service property and both annotations come from @Component. These three first controllers are using the EasyGreetingService because it's annotated with @Primary.

The fourth called it was to HelloControllerConstructorAndQualifier, this controller is using the @Qualifier("hardGreetingService") to say what implementation should be used, different from the others controllers previously created.

Then I have created a controller called ProfileController to show how the annotation @Profile can read the application.properties and choose a specific service. The default word was used if the properties doen't specify what profile to use.

Branch 4-jokes-app

In this branch, it was added a sample controller to print a random quote when the joke we page is visited.

Branch 5-spring-config

In this branch, it was added a type of spring conguration using annotation in the ChuckNorrisConfig class.

Branch 6-spring-config-xml

In this branch, it was added a type of spring conguration using xml in the chuck-config file.

Branch 7-property-source

In this branch, it was added one way to read a property file called fake.properties.

Branch 8-multi-source

In this branch, it was added a way to read properties from multi files.

Branch 9-recipe-app-models

In this branch, it was added the start source of Recipe APP. Basically, it was mapped to the models, services, repositories and one controller to show recipes.

Branch 10-CSS-Bootstrap-cdn

In this branch, it was added Bootstrap css using cdn and changing the index page to use it.

Branch 11-Start-tests

In this branch, it was added Some examples using tests.

Branch 12-Web-jars

In this branch, it was added web-jars to Bootstrap CSS and JQuery.

Branch 13-Recipe-show

In this branch, it was added a view to show the details about a recipe using TDD.