diff --git a/pom.xml b/pom.xml index 38812f09bf..f608f5cded 100644 --- a/pom.xml +++ b/pom.xml @@ -433,6 +433,7 @@ spring-data-couchbase-2 persistence-modules/spring-data-dynamodb spring-data-elasticsearch + spring-data-jpa spring-data-keyvalue spring-data-mongodb persistence-modules/spring-data-neo4j diff --git a/spring-data-jpa/pom.xml b/spring-data-jpa/pom.xml new file mode 100644 index 0000000000..517d43bd0e --- /dev/null +++ b/spring-data-jpa/pom.xml @@ -0,0 +1,26 @@ + + + + parent-boot-2 + com.baeldung + 0.0.1-SNAPSHOT + ../parent-boot-2 + + 4.0.0 + + spring-data-jpa + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + com.h2database + h2 + + + + \ No newline at end of file diff --git a/spring-data-jpa/src/main/java/com/baeldung/Application.java b/spring-data-jpa/src/main/java/com/baeldung/Application.java new file mode 100644 index 0000000000..43888c2d67 --- /dev/null +++ b/spring-data-jpa/src/main/java/com/baeldung/Application.java @@ -0,0 +1,14 @@ +package com.baeldung; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ApplicationContext; + +@SpringBootApplication +public class Application { + private static ApplicationContext applicationContext; + + public static void main(String[] args) { + applicationContext = SpringApplication.run(Application.class, args); + } +} diff --git a/spring-boot-persistence/src/main/java/com/baeldung/domain/Article.java b/spring-data-jpa/src/main/java/com/baeldung/domain/Article.java similarity index 100% rename from spring-boot-persistence/src/main/java/com/baeldung/domain/Article.java rename to spring-data-jpa/src/main/java/com/baeldung/domain/Article.java diff --git a/spring-boot-persistence/src/main/java/com/baeldung/repository/ArticleRepository.java b/spring-data-jpa/src/main/java/com/baeldung/repository/ArticleRepository.java similarity index 100% rename from spring-boot-persistence/src/main/java/com/baeldung/repository/ArticleRepository.java rename to spring-data-jpa/src/main/java/com/baeldung/repository/ArticleRepository.java diff --git a/spring-boot-persistence/src/test/java/com/baeldung/repository/ArticleRepositoryIntegrationTest.java b/spring-data-jpa/src/test/java/com/baeldung/repository/ArticleRepositoryIntegrationTest.java similarity index 97% rename from spring-boot-persistence/src/test/java/com/baeldung/repository/ArticleRepositoryIntegrationTest.java rename to spring-data-jpa/src/test/java/com/baeldung/repository/ArticleRepositoryIntegrationTest.java index 7d531d1461..dd1fe66a0d 100644 --- a/spring-boot-persistence/src/test/java/com/baeldung/repository/ArticleRepositoryIntegrationTest.java +++ b/spring-data-jpa/src/test/java/com/baeldung/repository/ArticleRepositoryIntegrationTest.java @@ -1,6 +1,7 @@ package com.baeldung.repository; import com.baeldung.domain.Article; +import com.baeldung.repository.ArticleRepository; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; diff --git a/spring-data-jpa/src/test/resources/application.properties b/spring-data-jpa/src/test/resources/application.properties new file mode 100644 index 0000000000..de6ee2e6b5 --- /dev/null +++ b/spring-data-jpa/src/test/resources/application.properties @@ -0,0 +1,15 @@ +# spring.datasource.x +spring.datasource.driver-class-name=org.h2.Driver +spring.datasource.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1 +spring.datasource.username=sa +spring.datasource.password=sa + +# hibernate.X +hibernate.dialect=org.hibernate.dialect.H2Dialect +hibernate.show_sql=true +hibernate.hbm2ddl.auto=create-drop +hibernate.cache.use_second_level_cache=true +hibernate.cache.use_query_cache=true +hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory + +spring.datasource.data=import_articles.sql \ No newline at end of file diff --git a/spring-boot-persistence/src/test/resources/import_articles.sql b/spring-data-jpa/src/test/resources/import_articles.sql similarity index 100% rename from spring-boot-persistence/src/test/resources/import_articles.sql rename to spring-data-jpa/src/test/resources/import_articles.sql