diff --git a/README.md b/README.md new file mode 100644 index 0000000..1354ac5 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# springBootBatch + +Spring Boot – Batch tutorial using MySQL, JPA and annotations + +In this example I show how to use Spring Boot to create a simple Spring Batch application. + +You can find more details here: +https://marco.dev/spring-boot-batch-tutorial-using-mysql-jpa-and-annotations +The only requirement is to have a mysql database installed. +You can find more information in the source code. + +If you start a new project in an IDE, you can simply create a simple new maven project (without Spring wizards or similar). + diff --git a/pom.xml b/pom.xml index 40e5f52..16f2588 100644 --- a/pom.xml +++ b/pom.xml @@ -6,11 +6,11 @@ springBootBatch springBootBatch - 0.1-SNAPSHOT + 0.3-SNAPSHOT org.springframework.boot spring-boot-starter-parent - 0.5.0.M5 + 2.4.3 @@ -24,32 +24,26 @@ mysql mysql-connector-java - 5.1.26 + [8.0.22,) + + + + javax.xml.bind + jaxb-api + 2.3.1 + + + org.glassfish.jaxb + jaxb-runtime + 2.3.3 - org.springframework.boot spring-boot-maven-plugin - - - - spring-snapshots - http://repo.spring.io/libs-snapshot - true - - - - - - spring-snapshots - http://repo.spring.io/libs-snapshot - true - - - \ No newline at end of file + diff --git a/src/main/java/ch/javaee/springBootBatch/Application.java b/src/main/java/ch/javaee/springBootBatch/Application.java index 4907e0b..cf9fa3f 100644 --- a/src/main/java/ch/javaee/springBootBatch/Application.java +++ b/src/main/java/ch/javaee/springBootBatch/Application.java @@ -1,7 +1,9 @@ package ch.javaee.springBootBatch; import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +@SpringBootApplication public class Application { public static void main(String args[]) { SpringApplication.run(BatchConfiguration.class, args); diff --git a/src/main/java/ch/javaee/springBootBatch/BatchConfiguration.java b/src/main/java/ch/javaee/springBootBatch/BatchConfiguration.java index dca4b47..5ee6826 100644 --- a/src/main/java/ch/javaee/springBootBatch/BatchConfiguration.java +++ b/src/main/java/ch/javaee/springBootBatch/BatchConfiguration.java @@ -179,7 +179,7 @@ public JpaVendorAdapter jpaVendorAdapter() { jpaVendorAdapter.setGenerateDdl(true); jpaVendorAdapter.setShowSql(false); - jpaVendorAdapter.setDatabasePlatform("org.hibernate.dialect.MySQLDialect"); + jpaVendorAdapter.setDatabasePlatform("org.hibernate.dialect.MySQL8Dialect"); return jpaVendorAdapter; } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 267db44..e57b73c 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -2,7 +2,15 @@ spring.jpa.hibernate.ddl-auto=create # no sql in the log spring.jpa.show-sql=false -database.driver=com.mysql.jdbc.Driver -database.url=jdbc:mysql://localhost:3306/BatchDB + +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect + +# updated to create the initial schema +spring.batch.initialize-schema=ALWAYS + +# schema for mysql >= 8 +database.driver=com.mysql.cj.jdbc.Driver + +database.url=jdbc:mysql://localhost:3306/batch_db_example database.username=root -database.password= \ No newline at end of file +database.password= diff --git a/src/main/resources/import.sql b/src/main/resources/import.sql index 0bd3b66..a99fb90 100644 --- a/src/main/resources/import.sql +++ b/src/main/resources/import.sql @@ -1,11 +1,11 @@ -drop table BatchDB.Batch_JOB_EXECUTION_CONTEXT; -drop table BatchDB.Batch_JOB_EXECUTION_PARAMS; -drop table BatchDB.Batch_JOB_EXECUTION_SEQ; -drop table BatchDB.Batch_JOB_SEQ; -drop table BatchDB.Batch_STEP_EXECUTION_CONTEXT; -drop table BatchDB.Batch_STEP_EXECUTION_SEQ; -drop table BatchDB.Batch_STEP_EXECUTION; -drop table BatchDB.Batch_JOB_EXECUTION; -drop table BatchDB.Batch_JOB_INSTANCE; +drop table batch_db_example.Batch_JOB_EXECUTION_CONTEXT; +drop table batch_db_example.Batch_JOB_EXECUTION_PARAMS; +drop table batch_db_example.Batch_JOB_EXECUTION_SEQ; +drop table batch_db_example.Batch_JOB_SEQ; +drop table batch_db_example.Batch_STEP_EXECUTION_CONTEXT; +drop table batch_db_example.Batch_STEP_EXECUTION_SEQ; +drop table batch_db_example.Batch_STEP_EXECUTION; +drop table batch_db_example.Batch_JOB_EXECUTION; +drop table batch_db_example.Batch_JOB_INSTANCE;