Create spring-boot-batch module

This commit is contained in:
Andy Wilkinson 2025-03-21 16:54:02 +00:00 committed by Phillip Webb
parent 087c8aa44b
commit 41c8b9faf0
32 changed files with 130 additions and 90 deletions

View File

@ -47,6 +47,7 @@ include "spring-boot-project:spring-boot-amqp"
include "spring-boot-project:spring-boot-artemis"
include "spring-boot-project:spring-boot-autoconfigure"
include "spring-boot-project:spring-boot-autoconfigure-all"
include "spring-boot-project:spring-boot-batch"
include "spring-boot-project:spring-boot-data-jpa"
include "spring-boot-project:spring-boot-dependencies"
include "spring-boot-project:spring-boot-devtools"

View File

@ -166,7 +166,6 @@ dependencies {
optional("org.springframework:spring-websocket")
optional("org.springframework:spring-webflux")
optional("org.springframework:spring-webmvc")
optional("org.springframework.batch:spring-batch-core")
optional("org.springframework.data:spring-data-couchbase")
optional("org.springframework.data:spring-data-envers") {
exclude group: "javax.activation", module: "javax.activation-api"

View File

@ -13,45 +13,6 @@
"description": "Whether subclass-based (CGLIB) proxies are to be created (true), as opposed to standard Java interface-based proxies (false).",
"defaultValue": true
},
{
"name": "spring.batch.initialize-schema",
"type": "org.springframework.boot.sql.init.DatabaseInitializationMode",
"deprecation": {
"replacement": "spring.batch.jdbc.initialize-schema",
"level": "error"
}
},
{
"name": "spring.batch.initializer.enabled",
"type": "java.lang.Boolean",
"description": "Create the required batch tables on startup if necessary. Enabled automatically\n if no custom table prefix is set or if a custom schema is configured.",
"deprecation": {
"replacement": "spring.batch.jdbc.initialize-schema",
"level": "error"
}
},
{
"name": "spring.batch.job.enabled",
"type": "java.lang.Boolean",
"description": "Execute all Spring Batch jobs in the context on startup.",
"defaultValue": true
},
{
"name": "spring.batch.schema",
"type": "java.lang.String",
"deprecation": {
"replacement": "spring.batch.jdbc.schema",
"level": "error"
}
},
{
"name": "spring.batch.table-prefix",
"type": "java.lang.String",
"deprecation": {
"replacement": "spring.batch.jdbc.table-prefix",
"level": "error"
}
},
{
"name": "spring.cassandra.compression",
"defaultValue": "none"

View File

@ -16,6 +16,5 @@ org.springframework.boot.autoconfigure.web.servlet.JspTemplateAvailabilityProvid
# Depends on Database Initialization Detectors
org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitializationDetector=\
org.springframework.boot.autoconfigure.batch.JobRepositoryDependsOnDatabaseInitializationDetector,\
org.springframework.boot.autoconfigure.quartz.SchedulerDependsOnDatabaseInitializationDetector,\
org.springframework.boot.autoconfigure.session.JdbcIndexedSessionRepositoryDependsOnDatabaseInitializationDetector

View File

@ -1,5 +1,4 @@
org.springframework.boot.autoconfigure.aop.AopAutoConfiguration
org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration
org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration
org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration
org.springframework.boot.autoconfigure.couchbase.CouchbaseAutoConfiguration

View File

@ -0,0 +1,31 @@
plugins {
id "java-library"
id "org.springframework.boot.auto-configuration"
id "org.springframework.boot.configuration-properties"
id "org.springframework.boot.deployed"
id "org.springframework.boot.optional-dependencies"
}
description = "Spring Boot Batch"
dependencies {
api(project(":spring-boot-project:spring-boot"))
api(project(":spring-boot-project:spring-boot-jdbc"))
api("org.springframework.batch:spring-batch-core")
implementation(project(":spring-boot-project:spring-boot-tx"))
optional(project(":spring-boot-project:spring-boot-autoconfigure"))
testImplementation(project(":spring-boot-project:spring-boot-flyway"))
testImplementation(project(":spring-boot-project:spring-boot-jpa"))
testImplementation(project(":spring-boot-project:spring-boot-liquibase"))
testImplementation(project(":spring-boot-project:spring-boot-test"))
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
testImplementation(testFixtures(project(":spring-boot-project:spring-boot-autoconfigure")))
testRuntimeOnly("ch.qos.logback:logback-classic")
testRuntimeOnly("com.fasterxml.jackson.core:jackson-databind")
testRuntimeOnly("com.h2database:h2")
testRuntimeOnly("com.zaxxer:HikariCP")
}

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.batch;
package org.springframework.boot.batch.autoconfigure;
import java.util.List;
@ -67,7 +67,7 @@ import org.springframework.util.StringUtils;
* @author Lars Uffmann
* @author Lasse Wulff
* @author Yanming Zhou
* @since 1.0.0
* @since 4.0.0
*/
@AutoConfiguration(after = TransactionAutoConfiguration.class,
afterName = "org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration")

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.batch;
package org.springframework.boot.batch.autoconfigure;
import org.springframework.batch.core.configuration.support.DefaultBatchConfiguration;
import org.springframework.core.convert.support.ConfigurableConversionService;
@ -26,7 +26,7 @@ import org.springframework.core.convert.support.ConfigurableConversionService;
* DefaultBatchConfiguration} while retaining its default auto-configuration.
*
* @author Claudio Nave
* @since 3.1.0
* @since 4.0.0
*/
@FunctionalInterface
public interface BatchConversionServiceCustomizer {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.batch;
package org.springframework.boot.batch.autoconfigure;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
@ -31,7 +31,7 @@ import org.springframework.context.annotation.Primary;
* {@link Primary @Primary}.
*
* @author Dmytro Nosan
* @since 2.2.0
* @since 4.0.0
*/
@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE, ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.batch;
package org.springframework.boot.batch.autoconfigure;
import java.util.List;
@ -33,7 +33,7 @@ import org.springframework.util.StringUtils;
* @author Vedran Pavic
* @author Andy Wilkinson
* @author Phillip Webb
* @since 2.6.0
* @since 4.0.0
*/
public class BatchDataSourceScriptDatabaseInitializer extends DataSourceScriptDatabaseInitializer {

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.batch;
package org.springframework.boot.batch.autoconfigure;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.sql.init.DatabaseInitializationMode;
@ -28,7 +28,7 @@ import org.springframework.transaction.annotation.Isolation;
* @author Vedran Pavic
* @author Mukul Kumar Chaundhyan
* @author Yanming Zhou
* @since 1.2.0
* @since 4.0.0
*/
@ConfigurationProperties("spring.batch")
public class BatchProperties {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.batch;
package org.springframework.boot.batch.autoconfigure;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
@ -32,7 +32,7 @@ import org.springframework.core.task.TaskExecutor;
* another one marked as {@link Primary @Primary}.
*
* @author Andy Wilkinson
* @since 3.4.0
* @since 4.0.0
*/
@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE, ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2024 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.batch;
package org.springframework.boot.batch.autoconfigure;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
@ -32,7 +32,7 @@ import org.springframework.transaction.PlatformTransactionManager;
* there is another one marked as {@link Primary @Primary}.
*
* @author Lasse Wulff
* @since 3.3.0
* @since 4.0.0
*/
@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE, ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.batch;
package org.springframework.boot.batch.autoconfigure;
import org.springframework.batch.core.JobExecution;
import org.springframework.context.ApplicationEvent;
@ -23,7 +23,7 @@ import org.springframework.context.ApplicationEvent;
* Spring {@link ApplicationEvent} encapsulating a {@link JobExecution}.
*
* @author Dave Syer
* @since 1.0.0
* @since 4.0.0
*/
@SuppressWarnings("serial")
public class JobExecutionEvent extends ApplicationEvent {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2022 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.batch;
package org.springframework.boot.batch.autoconfigure;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
@ -27,7 +27,7 @@ import org.springframework.context.ApplicationListener;
* {@link ExitCodeGenerator} for {@link JobExecutionEvent}s.
*
* @author Dave Syer
* @since 1.0.0
* @since 4.0.0
*/
public class JobExecutionExitCodeGenerator implements ApplicationListener<JobExecutionEvent>, ExitCodeGenerator {

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.batch;
package org.springframework.boot.batch.autoconfigure;
import java.util.Arrays;
import java.util.Collection;
@ -64,7 +64,7 @@ import org.springframework.util.StringUtils;
* @author Mahmoud Ben Hassine
* @author Stephane Nicoll
* @author Akshay Dubey
* @since 2.3.0
* @since 4.0.0
*/
public class JobLauncherApplicationRunner
implements ApplicationRunner, InitializingBean, Ordered, ApplicationEventPublisherAware {

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2021 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.batch;
package org.springframework.boot.batch.autoconfigure;
import java.util.Collections;
import java.util.Set;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,4 +17,4 @@
/**
* Auto-configuration for Spring Batch.
*/
package org.springframework.boot.autoconfigure.batch;
package org.springframework.boot.batch.autoconfigure;

View File

@ -0,0 +1,43 @@
{
"properties": [
{
"name": "spring.batch.initialize-schema",
"type": "org.springframework.boot.sql.init.DatabaseInitializationMode",
"deprecation": {
"replacement": "spring.batch.jdbc.initialize-schema",
"level": "error"
}
},
{
"name": "spring.batch.initializer.enabled",
"type": "java.lang.Boolean",
"description": "Create the required batch tables on startup if necessary. Enabled automatically\n if no custom table prefix is set or if a custom schema is configured.",
"deprecation": {
"replacement": "spring.batch.jdbc.initialize-schema",
"level": "error"
}
},
{
"name": "spring.batch.job.enabled",
"type": "java.lang.Boolean",
"description": "Execute all Spring Batch jobs in the context on startup.",
"defaultValue": true
},
{
"name": "spring.batch.schema",
"type": "java.lang.String",
"deprecation": {
"replacement": "spring.batch.jdbc.schema",
"level": "error"
}
},
{
"name": "spring.batch.table-prefix",
"type": "java.lang.String",
"deprecation": {
"replacement": "spring.batch.jdbc.table-prefix",
"level": "error"
}
}
]
}

View File

@ -0,0 +1,3 @@
# Depends on Database Initialization Detectors
org.springframework.boot.sql.init.dependency.DependsOnDatabaseInitializationDetector=\
org.springframework.boot.batch.autoconfigure.JobRepositoryDependsOnDatabaseInitializationDetector

View File

@ -0,0 +1 @@
org.springframework.boot.batch.autoconfigure.BatchAutoConfiguration

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.batch;
package org.springframework.boot.batch.autoconfigure;
import java.util.Arrays;
import java.util.Collection;
@ -58,8 +58,8 @@ import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.DefaultApplicationArguments;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
import org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration.SpringBootBatchConfiguration;
import org.springframework.boot.autoconfigure.batch.domain.City;
import org.springframework.boot.batch.autoconfigure.BatchAutoConfiguration.SpringBootBatchConfiguration;
import org.springframework.boot.batch.autoconfigure.domain.City;
import org.springframework.boot.flyway.autoconfigure.FlywayAutoConfiguration;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration;
@ -569,13 +569,13 @@ class BatchAutoConfigurationTests {
@Bean
DataSource normalDataSource() {
return DataSourceBuilder.create().url("jdbc:hsqldb:mem:normal").username("sa").build();
return DataSourceBuilder.create().url("jdbc:h2:mem:normal").username("sa").build();
}
@BatchDataSource
@Bean(defaultCandidate = false)
DataSource batchDataSource() {
return DataSourceBuilder.create().url("jdbc:hsqldb:mem:batchdatasource").username("sa").build();
return DataSourceBuilder.create().url("jdbc:h2:mem:batchdatasource").username("sa").build();
}
}
@ -585,7 +585,7 @@ class BatchAutoConfigurationTests {
@Bean
DataSource dataSource() {
return DataSourceBuilder.create().url("jdbc:hsqldb:mem:database").username("sa").build();
return DataSourceBuilder.create().url("jdbc:h2:mem:database").username("sa").build();
}
@Bean

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.batch;
package org.springframework.boot.batch.autoconfigure;
import javax.sql.DataSource;
@ -26,8 +26,8 @@ import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
import org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration.SpringBootBatchConfiguration;
import org.springframework.boot.autoconfigure.batch.domain.City;
import org.springframework.boot.batch.autoconfigure.BatchAutoConfiguration.SpringBootBatchConfiguration;
import org.springframework.boot.batch.autoconfigure.domain.City;
import org.springframework.boot.jdbc.autoconfigure.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.jdbc.autoconfigure.EmbeddedDataSourceConfiguration;
import org.springframework.boot.sql.init.DatabaseInitializationMode;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.batch;
package org.springframework.boot.batch.autoconfigure;
import java.io.IOException;
import java.sql.Connection;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.batch;
package org.springframework.boot.batch.autoconfigure;
import org.junit.jupiter.api.Test;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.batch;
package org.springframework.boot.batch.autoconfigure;
import org.junit.jupiter.api.Test;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.batch;
package org.springframework.boot.batch.autoconfigure;
import java.util.Arrays;
import java.util.List;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.batch.domain;
package org.springframework.boot.batch.autoconfigure.domain;
import java.io.Serializable;

View File

@ -2019,6 +2019,7 @@ bom {
"spring-boot-artemis",
"spring-boot-autoconfigure",
"spring-boot-autoconfigure-processor",
"spring-boot-batch",
"spring-boot-buildpack-platform",
"spring-boot-configuration-metadata",
"spring-boot-configuration-processor",

View File

@ -59,6 +59,7 @@ dependencies {
autoConfiguration(project(path: ":spring-boot-project:spring-boot-artemis", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-autoconfigure", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-autoconfigure-all", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-batch", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-data-jpa", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-devtools", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-elasticsearch", configuration: "autoConfigurationMetadata"))
@ -93,6 +94,7 @@ dependencies {
configurationProperties(project(path: ":spring-boot-project:spring-boot-artemis", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-autoconfigure", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-autoconfigure-all", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-batch", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-data-jpa", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-devtools", configuration: "configurationPropertiesMetadata"))
configurationProperties(project(path: ":spring-boot-project:spring-boot-docker-compose", configuration: "configurationPropertiesMetadata"))

View File

@ -5,7 +5,7 @@ plugins {
description = "Starter for using Spring Batch"
dependencies {
api(project(":spring-boot-project:spring-boot-batch"))
api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter"))
api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-jdbc"))
api("org.springframework.batch:spring-batch-core")
}