This project provides basic skeleton setup for a Spring Data JPA based app. It will set up the following:
- A plain Java project based on the latest Spring Data JPA and Hibernate as persistence provider using an HSQL in-memory database by default and Logback for logging.
- The necessary Spring JavaConfig configuration (
ApplicationConfig
incom.acme
insidesrc/main/java
) to set up aDataSource
,EntityManagerFactory
,JpaTransactionManager
and activate Spring Data repositories. - A sample
ApplicationTest
(incom.acme
insidesrc/test/java
) to bootstrap this configuration.
To adapt the skeleton to your needs you mostly need to do the following:
- Adapt groupId and artifactId according to your project requirements
- Optionally choose your persistence provider and adapt
pom.xml
accordingly, the default uses Hibernate. If you switch to a different persistence provider make sure you adapt the configuration of theLocalContainerEntityManagerFactoryBean
insideapplication-context.xml
. - Create entities and repositories inside
src/main/java
according to your project and adapt thebase-package
attribute in the<jpa:repositories />
element insidesrc/main/resources/META_INF/spring/application-context.xml
as well as thepackagesToScan
property of theLocalContainerEntityManagerFactoryBean
.