Mathias Hauser

My opinions and thoughts on various things and experiences of software development

Category Archives: Spring Data JPA

How to configure Spring Boot with JPA and multiple projects

Its a common case to split up a project into multiple sub projects with a project containing classes used in multiple projects.
This is a fairly simple task related to dependency management, but can lead to problems in combination with Spring and JPA. I will explain you in this post what needs to be done to get everything up and running.

I recommend downloading the source of this example before you start. Link to the repository blog_springBoot-jpa-multiProject direct link to the source zip source-zip

Content of this post

  • Project structure & Gradle setup – A minimal setup to show that the approach works
  • JPA Entity and Repository – A JPA Test entity and Spring Data JPA repository for db interaction
  • Spring Boot Application configuration class – Set the Spring scan packages
  • Database configuration – Set the JPA scan package

Read more of this post

Advertisements

Bootstrap an application with Spring Boot – Part1 Command-line

Spring Boot is a new piece of technology with the aim to reduce the configuration overhead and easier project bootstrap. There are many little examples out there which describe how to use it, but there is in many cases something that you don’t want or a configuration parameter you need, but not mentioned in a specific tutorial. I try to give you a good starting point for you application plus additional references to additional informations you might need for your setup.

Command-line application with Spring Boot

Most Spring Boot examples are web applications. This is ok because many new applications are web based, but its not optimal in each situation. I personally prefer to start with as little new as possible. My experience is that solving problems with two new things cost more time than solving one after another. So I decided to start things off with a really simple command-line application which allows inserting a word with a specific text to the database.

I recommend downloading the source of this example before you start. Link to the repository blog_springBoot-commandLine direct link to the source zip source-zip

Four key points of the configuration

  1. Build- and Dependencymanagement -> build.gradle -> in the project root
  2. Application configuration -> Application.java -> anywhere in your package structure in this case mh.dev.blog (src/main/java)
  3. Property configuration -> application.yml -> src/main/resources
  4. Logging configuration -> logback.xml -> src/main/resources

Read more of this post