Home » Tag Archives: Spring (page 3)

Tag Archives: Spring

Access the EntityManager from Spring Data JPA

spring-interview-questions-answers

Spring Data JPA allows you to rapidly develop your data access layer through the use of Repository interfaces. Occasionally you will need to access the EntityManager from Spring Data JPA. This post shows you how to access the EntityManager. EntityManager The purpose of the EntityManager is to interact with the persistence context. The persistence context will then manage entity instances ...

Read More »

Add EntityManager.refresh to all Spring Data Repositories

spring-interview-questions-answers

In my previous post Access the EntityManager from Spring Data JPA I showed how to extend a single Spring Data JPA repository to access the EntityManager.refresh method. This post demonstrates how to Add EntityManager.refresh to all Spring Data Repositories. Source Code The first step is to define your interface – package com.glenware.springboot.repository; import org.springframework.data.repository.NoRepositoryBean; import org.springframework.data.repository.Repository; import org.springframework.data.repository.CrudRepository; import java.io.Serializable; ...

Read More »

Using MySQL JDBC Driver With Spring Boot

In this article, I will show you how to connect a MySQL database with your Spring Boot application. Tools used in this article include: Spring Boot 1.5.6 Release MySQL 5.7.X Maven Java 8 Spring Data JPA 1 – Project Structure The project structure is a typical Maven structure. 2 – Project Dependencies Please note that the parent needs to declared. ...

Read More »

PagingAndSortingRepository – How to Use With Thymeleaf

For this tutorial, I will demonstrate how to display a list of a business’ clients in Thymeleaf with pagination. 1 – Project Structure We have a normal Maven project structure. 2 – Project Dependencies Besides the normal Spring dependencies, we add Thymeleaf and hsqldb because we are using an embedded database. <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> ...

Read More »

Validation in Thymeleaf + Spring

Overview Important topics we will be discussing are dealing with null values, empty strings, and validation of input so we do not enter invalid data into our database. In dealing with null values, we touch on use of java.util.Optional which was introduced in Java 1.8. 0 – Spring Boot + Thymeleaf Example Form Validation Application We are building a web ...

Read More »

Building Spring Boot RESTful Service + Spring Boot Actuator

Overview What is REST? REST(REpresentational State Transfer) is the architectural style the web is built on and has become a standard software design pattern used for web applications. The term Representational State Transfer was first used by Roy Fielding, the originator of REST and one of the principal authors of HTTP specification, in his doctoral dissertation. There are many good ...

Read More »

DispatcherServlet of Spring MVC – 10 things Java Developer should know

spring-interview-questions-answers

If you have worked with Spring MVC then you should know what is a DispatcherServlet? It’s actually the heart of Spring MVC, precisely the C of MVC design pattern or Controller. Every single web request which is supposed to be processed by Spring MVC goes through DispatcherServlet. In general, its an implementation of Front Controller Pattern which provides a single point ...

Read More »

Secure REST Service with OAuth2 Tokens

spring-interview-questions-answers

1. Introduction In this tutorial, we will check out how we can use Spring Security with OAuth to secure REST Service. In the demo application, the secured REST resources on the server are accessible with the path pattern (/api/**), such that the request URLs based on this path are mapped to different controller methods. This means that – Any REST ...

Read More »