Ehcache is an open source, standards-based cache that boosts performance. It’s the most widely-used Java-based cache because it’s robust, proven, full-featured, and integrates with other popular libraries and frameworks. In this example I will show you how to use Ehcache in a Spring Boot application. NOTE: If you need to know what tools you need to have installed in your computer in order to create a Spring Boot basic project, please refer my previous post: Spring Boot
[Read More]
Spring Boot Oauth2 with Google
This time I will show you how to build a basic Spring Boot application with Google authentication using Oauth2.
NOTE: If you need to know what tools you need to have installed in yout computer in order to create a Spring Boot basic project, please refer my previous post: Spring Boot
Then execute this command in your terminal:
spring init --dependencies=web,security,thymeleaf --language=groovy --build=gradle spring-boot-oauth2 This is the build.gradle generated file:
[Read More]
Spring Boot Swagger
Open API specification, previously known as Swagger specification defines standard, language-agnostic interface to RESTful API’s which allows to understand service’s capabilities without access the code. Where you can keep your documentation attached with the evolution of your project. With Swagger UI you will have a web interface that allows you to easily interact with API’s resources without having any implamentation in place. An Open API specification can then be used by code generation tools to generate servers and clients, testing tools and many more.
[Read More]
Spring Boot Thymeleaf Layouts
This time I will show you how to share common page components like header, footer called layouts using Thymeleaf. Go here for more information. Let’s consider the following home page:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <link rel="stylesheet" href="/assets/third-party/bootstrap/dist/css/bootstrap.min.css" /> <link rel="stylesheet" href="/assets/third-party/font-awesome/font-awesome.less" /> </head> <body> <nav class="navbar navbar-inverse navbar-fixed-top"> <a class="navbar-brand" href="/"> <img src="/assets/third-party/vetlog-theme/img/flex-admin-logo.png" th:src="@{/assets/third-party/vetlog-theme/img/flex-admin-logo.png}"/> </a> </nav> <nav class="navbar-top" role="navigation"> <div class="navbar-brand"> </div> </nav> <div class="jumbotron"> <div class="container"> <h1>Welcome!
[Read More]
Spring Boot Logback
Logback is a logging framework wheter console or file, is nowadays the best option for logging your Spring Boot application. Here you can find more information about it. This time I will show you how to configure Logback.
First you need to add logback dependencies into your build.gradle file.
compile "ch.qos.logback:logback-classic:1.2.1" compile "ch.qos.logback:logback-core:1.2.1" Then under ${PROJECT_HOME}/src/main/resources create this logback.groovy file:
import ch.qos.logback.core.ConsoleAppender import ch.qos.logback.core.rolling.RollingFileAppender import ch.qos.logback.classic.encoder.PatternLayoutEncoder import static ch.qos.logback.classic.Level.DEBUG import static ch.
[Read More]
Spring Boot Liquibase
Liquibase is a source control for your databases. This time I will show you how to add Liquibase to a Spring Boot project. First you need to add your Liquibase dependency in your build.gradle file
compile "org.liquibase:liquibase-core:3.5.3" Concepts
Changelog: Developers store database changes in text-based files on their local development machines and apply them to their local databases.
ChangeSet: Are uniquely identified by the “author” and “id” attribute. Each changeset generally contains a change which describes the change/refactoring to apply to the database.
[Read More]
Spring Boot Flyway
In the same way, we find benefits in using version of control in software development with Git; we can version our database to manage changes in schema and information. Let’s go over Flyway, an open source project that help us to implement database migrations easily; that’s it, how cool would it be to see our database evolution across our development life cycle? In this example, we wil be using Gradle and Spring Boot.
[Read More]
Spring Boot JDBC Template
Spring JDBC template provide an abstraction that makes easy for you to implement relational database operations within a Spring Boot application. Spring JdbcTemplate is the central class in the JDBC core package.
Query for Multiple Rows Query for Object Query for Update Let’s start creating a new Spring Boot project with web and jdbc dependencies:
spring init --dependencies=web,jdbc --language=java --build=gradle spring-boot-jdbc-template This is the build.gradle file generated:
plugins { id 'org.
[Read More]
Spring Boot Actuator
Spring Boot includes a number of additional features to help you monitor and manage your application. The spring-boot-actuator module provides all of Spring Boot’s production-ready features.
Let’s start creating a new Spring Boot project with web and actuator dependencies:
spring init --dependencies=web,actuator --language=groovy --build=gradle spring-boot-actuator This is the build.gradle file generated:
buildscript { ext { springBootVersion = '1.5.12.RELEASE' } repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } } apply plugin: 'groovy' apply plugin: 'org.
[Read More]
Spring Boot Rest Client
This time I will show you how to consume a REST service using Spring Boot and a Groovy library based in HTTPBuilder RESTClient by jgritman.
Let’s start creating a new Spring Boot project with web dependencies:
spring init --dependencies=web --build=gradle --language=groovy spring-boot-rest-client Here is the complete build.gradle file generated:
buildscript { ext { springBootVersion = '1.5.12.RELEASE' } repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } } apply plugin: 'groovy' apply plugin: 'org.
[Read More]