This tutorial has been created to help anyone to create a Java web application based on Spring, Vaadin, Hibernate + JPA2.0. We will try to guide you step by step from the project structure creation to have a simple and easy web application.
We have chosen this technologies’s combination in this tutorial because the same is being used in our real projects!
Our first goal is try to have an application updated, easily maintained and robust.
The language used to develop is Java 8 and we use IntelliJ IDEA as Integrated Development Environment – IDE (Version 15.0.3 – Community). The frameworks and its versions used for this tutorial:
- Vaadin as web application framework. Version 7.5.9.
- Spring as dependency injector framework. Version 4.1.6.RELEASE.
- Hibernate as ORM solution. Version 4.2.3.Final.
- JPA 2.0 as persistence API. Version 1.0.1.Final.
How is the project structure?
The project is a multi-module project divided in 3 layers:
- Persistence: Jpa, to manage, access and persist the data. Here is where we will create our entities. It’s a jar library.
- Core: Spring, for the application and business logic, services.. It’s a jar library too.
- Web: Vaadin, to interact with the user, it’s the UI layer. It’s a war.
And with the following relations:
- Core depends on persistence
- Web depends on core.
The multilayer structure provides us:
- More flexibility and scalability
- Less costs to install
- Easy to switch between different databases
- Insulation against changes
- Central resources management
- Easy to localize bugs
Some general project configuration details to keep in mind:
- At the following steps we will identify the required components and describe how we can get them by using Maven 3.1.
- Encoding: UTF-8
- We recommend to use a tool to analyse the code, mainly if you are starting. We use Sonarqube platform to manage code quality. You can use directly a plugin as Sonarlint to check the code from the IDE.