Aug 13, 2015

Spring Hibernate Workspace creation

While developing any complex system it is advisable to break the entire project in to small (probably) reusable components and as and when required include one (maven) project in another. In this blog lets create eclipse workspace for with following frameworks. This workspace will basically serve the purpose of developing core components of any project. We will use World Database made available by MySQL instead of running around to create some hypothetical application.
  • Spring (core, context and orm)
  • Hibernate
  • Spring Data JPA
  • slf4j with log4j (for logging and flexibility to move from log4j to any other logging mechanism)
  • JUnit
  • MySQL Driver (assuming most of your projects will need same DB, if there are more DB then load all drivers)
So first create a maven project in eclipse.



Now edit pom.xml as follows.


There are few points here

  • Use dependency management tag to ensure all project and sub-projects extend this core project and they use same version of libraries rather then loading different version of libraries for different project.
  • All the libraries that you may possibly use in projects (or sub-projects) at later stage need to have entry in <dependencyManagement> in pom.xml of this core project.
  • Under dependencies use only libraries that are part of this project e.g. Spring integration is not required in core project then do not include it in core project
Once this workspace is created in next few articles we will build a sample code to use Spring, Spring integration, Spring batch and Spring Data JPA frameworks.