diff --git a/persistence-modules/spring-jdbc-batch/pom.xml b/persistence-modules/spring-jdbc-batch/pom.xml deleted file mode 100644 index 0401044be1..0000000000 --- a/persistence-modules/spring-jdbc-batch/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - 4.0.0 - - spring-jdbc-batch - 0.0.1-SNAPSHOT - spring-jdbc-batch - Demo project for Spring Boot Jdbc batch support - - - com.baeldung - parent-boot-2 - 0.0.1-SNAPSHOT - ../../parent-boot-2 - - - - - 11 - - - - - - org.springframework.boot - spring-boot-starter-jdbc - - - org.postgresql - postgresql - runtime - - - org.springframework.boot - spring-boot-starter-test - test - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - org.apache.maven.plugins - maven-compiler-plugin - - ${java.version} - ${java.version} - - - - - diff --git a/persistence-modules/spring-jdbc/pom.xml b/persistence-modules/spring-jdbc/pom.xml index 28a858dd43..08e43e8292 100644 --- a/persistence-modules/spring-jdbc/pom.xml +++ b/persistence-modules/spring-jdbc/pom.xml @@ -31,6 +31,11 @@ mysql-connector-java runtime + + org.postgresql + postgresql + runtime + \ No newline at end of file diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java similarity index 88% rename from persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java index 008bf55024..280f9cf2be 100644 --- a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/SpringJdbcBatchPerformanceApplication.java @@ -1,14 +1,17 @@ package com.baeldung.spring.jdbc.batch; import com.baeldung.spring.jdbc.batch.service.ProductService; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +import java.util.Collections; @SpringBootApplication +@ComponentScan(basePackages = "com.baeldung.spring.jdbc.batch") public class SpringJdbcBatchPerformanceApplication implements CommandLineRunner { @Autowired @@ -30,7 +33,7 @@ public class SpringJdbcBatchPerformanceApplication implements CommandLineRunner long regularElapsedTime = simpleProductService.createProducts(recordCount); long batchElapsedTime = batchProductService.createProducts(recordCount); - System.out.println("-".repeat(50)); + System.out.println(String.join("", Collections.nCopies(50, "-"))); System.out.format("%-20s%-5s%-10s%-5s%8sms\n", "Regular inserts", "|", recordCount, "|", regularElapsedTime); System.out.format("%-20s%-5s%-10s%-5s%8sms\n", "Batch inserts", "|", recordCount, "|", batchElapsedTime); System.out.printf("Total gain: %d %s\n", calculateGainInPercent(regularElapsedTime, batchElapsedTime), "%"); diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java similarity index 85% rename from persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java index b0fd111ed2..45d80f924a 100644 --- a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java +++ b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/config/AppConfig.java @@ -5,11 +5,13 @@ import com.baeldung.spring.jdbc.batch.repo.SimpleProductRepository; import com.baeldung.spring.jdbc.batch.service.ProductService; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; import java.time.Clock; import java.util.Random; @Configuration +@PropertySource("classpath:com/baeldung/spring/jdbc/batch/application.properties") public class AppConfig { @Bean diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/model/Product.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/model/Product.java similarity index 100% rename from persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/model/Product.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/model/Product.java diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/BatchProductRepository.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/BatchProductRepository.java similarity index 100% rename from persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/BatchProductRepository.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/BatchProductRepository.java diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/ProductRepository.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/ProductRepository.java similarity index 100% rename from persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/ProductRepository.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/ProductRepository.java diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/SimpleProductRepository.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/SimpleProductRepository.java similarity index 100% rename from persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/repo/SimpleProductRepository.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/repo/SimpleProductRepository.java diff --git a/persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java b/persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java similarity index 100% rename from persistence-modules/spring-jdbc-batch/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java rename to persistence-modules/spring-jdbc/src/main/java/com/baeldung/spring/jdbc/batch/service/ProductService.java diff --git a/persistence-modules/spring-jdbc-batch/src/main/resources/application.properties b/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/batch/application.properties similarity index 96% rename from persistence-modules/spring-jdbc-batch/src/main/resources/application.properties rename to persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/batch/application.properties index 3f9b093013..9898ae022b 100644 --- a/persistence-modules/spring-jdbc-batch/src/main/resources/application.properties +++ b/persistence-modules/spring-jdbc/src/main/resources/com/baeldung/spring/jdbc/batch/application.properties @@ -2,4 +2,4 @@ spring.datasource.url=jdbc:postgresql://localhost:5432/sample-baeldung-db spring.datasource.username=postgres spring.datasource.password=root spring.datasource.driver-class-name=org.postgresql.Driver -spring.datasource.hikari.data-source-properties.reWriteBatchedInserts=true +spring.datasource.hikari.data-source-properties.reWriteBatchedInserts=true \ No newline at end of file diff --git a/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java b/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java similarity index 99% rename from persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java rename to persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java index 26a5f64dc0..f19c2360f4 100644 --- a/persistence-modules/spring-jdbc-batch/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java +++ b/persistence-modules/spring-jdbc/src/test/java/com/baeldung/spring/jdbc/batch/service/ProductServiceUnitTest.java @@ -2,7 +2,6 @@ package com.baeldung.spring.jdbc.batch.service; import com.baeldung.spring.jdbc.batch.model.Product; import com.baeldung.spring.jdbc.batch.repo.ProductRepository; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/pom.xml b/pom.xml index 23cc338d8b..24aa678523 100644 --- a/pom.xml +++ b/pom.xml @@ -1260,7 +1260,6 @@ testing-modules/testing-assertions persistence-modules/fauna lightrun - persistence-modules/spring-jdbc-batch @@ -1328,7 +1327,6 @@ spring-boot-modules/spring-boot-camel testing-modules/testing-assertions persistence-modules/fauna - persistence-modules/spring-jdbc-batch lightrun