Testing in Spring Boot 2

Learn to write unit tests and integration tests in spring boot applications along with spring test context, test annotations and bean mocking support.

How to Write Integration Test in Spring Boot

Learn to write integration tests for given Spring rest controller apis using @SpringBootTest and Junit 5. This technique can be applied to spring boot as well as spring mvc applications, both.

Spring boot – @SpringBootTest

Learn about @SpringBootTest annotation provided by Spring boot to enable boot specific features in the tests during unit testing or integration testing.

Configure Hibernate with Spring Boot

Learn to configure hibernate/JPA support in Spring Boot2 applications, along with creating entity classes and extending inbuilt JpaRepository interfaces.

Spring Boot with H2 Database

Learn to configure Spring boot with H2 database to create and use an in-memory database in runtime, generally for unit testing or POC purposes.

Spring Batch Quartz Java Config Example

Learn to configure Quartz scheduler to run Spring batch jobs configured using Spring boot Java configuration. Although, Spring’s default scheduler is also good, but quartz does the scheduling and invocation of tasks much better and in more configurable way. This leaves Spring batch to focus on creating batch jobs only, and let quartz execute them. … Read more

Bootstrapping a REST API with Spring Boot

Spring boot is sub-project developed by developers of spring framework – to create stand-alone, production-grade application with minimum configuration possible. Spring boot applications are typically bundled as fat/uber jar files and can be deployed in any platform as a simple jar file. This is why spring boot applications are a good candidate for building microservices in java.

JPA Tutorials

The Java Persistence API (JPA) is a Java application programming interface specification that describes the management of relational data in applications using Java Platform, Standard Edition and Java Platform, Enterprise Edition. This page lists down all tutorials available on this blog related to JPA. JPA Basics Field vs Property vs Mixed Access modes CRUD Operations … Read more

Configure JPA without persistence.xml

If you are working on Spring project and using JPA for data access, then you probably have persistence.xml file as well in META-INF folder. If you want to get rid of persistence.xml and configure datasource, persistence units name and entity paths in spring’s application-context.xml only then you can do it as below while configuring entityManagerFactoryBean. … Read more

Spring Hibernate JPA Configuration Example

In this example, we will learn to configure Spring MVC and Hibernate with JPA along with few other things e.g. validation and custom property editors. I have been asked quite enough times to write this tutorial in past, so here it is. Feel free to post your doubts, comments and suggestions. If you want to … Read more

Tomcat – Architecture and server.xml configuration

We already learnt how webservers work in general when you deploy your web application on server and access from a browser. Now let’s learn the stuffs inside server which may not be used in day to day job, but they will certainly help you when you are configuring your application first time. I have been … Read more

Spring WebMVC Interview Questions

Spring MVC Interview Questions and answers. These have been written to help beginners as well as experienced developers to prepare for their next interview.

Spring Interview Questions with Answers

This page lists the most asked and important Spring framework interview questions that we may face in our next job interview. 1. What is Spring Framework? What are it’s Main Modules? Spring is probably the most used Java framework for developing simple web applications to enterprise-class cloud applications and microservices. Spring provides comprehensive infrastructure support … Read more

Spring RestTemplate (with Examples)

Learn to create Spring REST client using Spring RestTemplate class and it’s template methods to access HTTP GET, POST, PUT and DELETE requests in easy step.

Guide to Hibernate Criteria Queries

Learn about hibernate Criteria query interface, its basics, syntax, fetching data with multiple conditions including pagination and sorting.

Spring 4 + Struts 2 + Hibernate Integration Tutorial

Previously, I have covered spring 3 + hibernate integration example and struts 2 hello world example. In this tutorial, I am discussing all important points to keep in mind when integration spring framework with struts in conjunction with hibernate. Also, please note that this tutorial uses other minor yet important concepts such as logging, use … Read more

Real Java Interview Questions asked in Oracle

Sreenath Ravva, one of the readers of HowToDoInJava, has appeared in an interview in Oracle for a position in the Oracle Enterprise Manager product. The below-listed questions were shared by him so that I can share them with all of you, in hope that it will benefit few of us on any fine day. I … Read more

Spring AbstractRoutingDataSource Example

AbstractRoutingDataSource is a very useful feature if we have a design which permits multiple databases based on certain criteria which may change for each user request. An example can be when we can use a particular database when the user belongs to a certain locale and switch to another locale if the user belongs to … Read more

[SOLVED] java.lang.NoClassDefFoundError: Lorg/hibernate/cache/CacheProvider

If you are trying to setup your project/ or adding dependency for hibernate 4 then you might face this error in your server logs. Stack-trace will be looking like this: Solution: Reason is that you have incompatible jar’s versions in your application classpath. To resolve this issue, make sure you have compatible jars. Sample configuration … Read more

Why are Strings Immutable in Java?

The immutable strings help in achieving the required data safety and performance in a Java application with help of underlying string pool.

Spring Security Siteminder Pre-authentication Example

So far we have learned about securing spring application using login form based security, custom user details security and many more such security related concepts. In this post, I am giving an example of scenario where use is already authenticated via any third party application or tool e.g. site minder which is very common interface … Read more

Java Best Practices Guide

A good programmer is one who write programs (not just code). It means writing the code units which are independent enough to be re-used in multiple ways, and still they remain robust. So let’s start identifying and learning some java best practices which can transform any code into the programs. 1. Java Design Best Practices … Read more

Hibernate Named Query Examples

Learn to create, group and execute named HQL and named native SQL queries in Hibernate using @NamedQuery and @NamedNativeQuery annotations.

Inserting Objects with Hibernate

Learn to insert an object into the database using hibernate’s Session interface, JPA’s EntityManager and HQL Query interface with examples.

Test Spring Security Auth with JUnit

Learn to test Spring security authentication using JUnit testcase using InMemoryDaoImpl. Also learn to build fully populated authentication object programmatically and then use it in application. SecurityContextHolder Spring security is based on security context, which is kind of static in nature. This essentially means that your do not need to inject its reference into your … Read more

Spring View Layer Security using JSP Taglibs

So far in previous tutorials, we have learned about securing your application behind login form, custom user detail service and even method level security also. All these security implementations were on controller or model layer of MVC. Its time to add security in view layer. It is mostly needed when we want to hide certain … Read more

Java Interview Questions and Answers

Read all the Java interview questions and answers in this article to refresh your concepts and possibly have some new ones added to the list.

SQLException: Access denied for user ‘root’@’localhost’

Have you ever faced problem of Access denied for user or any login related issues after re-installing MySQL server. I faced this issue and when I googled it, I saw many others are also suffering from this problem frequently. In this post, I will suggest you a good try which will solve this problem in … Read more

Hibernate Hello World Example

Step by step hibernate hello world example with maven and eclipse. Learn to create, configure and store hibernate 5 entities in the database.

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.