Deprecate redundant APIs

This commit deprecates redundant APIs to simplify the way to
configure and use Spring Batch. The most notable changes are:

- JobLauncher is deprecated in favor of JobOperator
- JobExplorer is deprecated in favor of JobRepository
- CommandLineJobRunner is deprecated in favor of more
modern alternatives like Spring Boot's job Launcher

Other APIs that are only used in the newly deprecated APIs
have been deprecated as well.

Resolves #4847
This commit is contained in:
Mahmoud Ben Hassine
2025-06-12 08:25:03 +02:00
parent 4fbac1f9e5
commit bfe487cccc
14 changed files with 50 additions and 14 deletions

View File

@@ -34,8 +34,11 @@ import org.springframework.batch.core.repository.JobRestartException;
* @author Dave Syer
* @author Taeik Lim
* @author Mahmoud Ben Hassine
*
* @deprecated since 6.0 in favor of {@link JobOperator}. Scheduled for removal in 6.2 or later.
*/
@FunctionalInterface
@Deprecated(since = "6.0", forRemoval = true)
public interface JobLauncher {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2023 the original author or authors.
* Copyright 2006-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.
@@ -41,12 +41,8 @@ import org.springframework.batch.core.configuration.JobLocator;
import org.springframework.batch.core.configuration.JobRegistry;
import org.springframework.batch.core.converter.DefaultJobParametersConverter;
import org.springframework.batch.core.converter.JobParametersConverter;
import org.springframework.batch.core.launch.*;
import org.springframework.batch.core.repository.explore.JobExplorer;
import org.springframework.batch.core.launch.JobExecutionNotFailedException;
import org.springframework.batch.core.launch.JobExecutionNotRunningException;
import org.springframework.batch.core.launch.JobExecutionNotStoppedException;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.launch.NoSuchJobException;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
@@ -173,7 +169,10 @@ import org.springframework.util.StringUtils;
* @author Mahmoud Ben Hassine
* @author Minsoo Kim
* @since 1.0
*
* @deprecated since 6.0 with no replacement. Scheduled for removal in 6.2 or later.
*/
@Deprecated(since = "6.0", forRemoval = true)
public class CommandLineJobRunner {
protected static final Log logger = LogFactory.getLog(CommandLineJobRunner.class);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2013 the original author or authors.
* Copyright 2006-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.
@@ -24,7 +24,9 @@ package org.springframework.batch.core.launch.support;
* @author Lucas Ward
* @author Dave Syer
*
* @deprecated since 6.0 with no replacement. Scheduled for removal in 6.2 or later.
*/
@Deprecated(since = "6.0", forRemoval = true)
public class JvmSystemExiter implements SystemExiter {
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2023 the original author or authors.
* Copyright 2006-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.
@@ -20,8 +20,11 @@ import org.aopalliance.intercept.MethodInvocation;
/**
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
* @deprecated since 6.0 with no replacement, for removal in 6.2 or later.
*/
@Deprecated(since = "6.0", forRemoval = true)
public class RuntimeExceptionTranslator implements MethodInterceptor {
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2023 the original author or authors.
* Copyright 2006-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.
@@ -22,7 +22,9 @@ package org.springframework.batch.core.launch.support;
*
* @author Lucas Ward
*
* @deprecated since 6.0 with no replacement. Scheduled for removal in 6.2 or later.
*/
@Deprecated(since = "6.0", forRemoval = true)
public interface SystemExiter {
/**

View File

@@ -65,7 +65,10 @@ import org.springframework.util.Assert;
* @since 1.0
* @see JobRepository
* @see TaskExecutor
*
* @deprecated since 6.0 in favor of {@link TaskExecutorJobOperator}. Scheduled for removal in 6.2 or later.
*/
@Deprecated(since = "6.0", forRemoval = true)
public class TaskExecutorJobLauncher implements JobLauncher, InitializingBean {
protected static final Log logger = LogFactory.getLog(TaskExecutorJobLauncher.class);

View File

@@ -24,6 +24,7 @@ import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.launch.NoSuchJobException;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.lang.Nullable;
@@ -38,7 +39,10 @@ import org.springframework.lang.Nullable;
* @author Mahmoud Ben Hassine
* @author Parikshit Dutta
* @since 2.0
*
* @deprecated since 6.0 in favor of {@link JobRepository}. Scheduled for removal in 6.2 or later.
*/
@Deprecated(since = "6.0", forRemoval = true)
public interface JobExplorer {
/*

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2023 the original author or authors.
* Copyright 2006-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.
@@ -43,7 +43,10 @@ import org.springframework.util.Assert;
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @since 2.0
*
* @deprecated since 6.0 with no replacement. Scheduled for removal in 6.2 or later.
*/
@Deprecated(since = "6.0", forRemoval = true)
public abstract class AbstractJobExplorerFactoryBean implements FactoryBean<JobExplorer>, InitializingBean {
private static final String TRANSACTION_ISOLATION_LEVEL_PREFIX = "ISOLATION_";

View File

@@ -16,6 +16,7 @@
package org.springframework.batch.core.repository.explore.support;
import org.springframework.batch.core.repository.support.JdbcJobRepositoryFactoryBean;
import org.springframework.beans.factory.FactoryBean;
/**
@@ -25,9 +26,11 @@ import org.springframework.beans.factory.FactoryBean;
*
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @since 6.0
*
* @deprecated since 6.0 in favor of {@link JdbcJobRepositoryFactoryBean}. Scheduled for removal in 6.2 or later.
*/
@SuppressWarnings("removal")
@Deprecated(since = "6.0", forRemoval = true)
public class JdbcJobExplorerFactoryBean extends JobExplorerFactoryBean {
}

View File

@@ -42,6 +42,7 @@ import org.springframework.batch.core.repository.dao.jdbc.JdbcStepExecutionDao;
import org.springframework.batch.core.repository.dao.JobExecutionDao;
import org.springframework.batch.core.repository.dao.JobInstanceDao;
import org.springframework.batch.core.repository.dao.StepExecutionDao;
import org.springframework.batch.core.repository.support.JdbcJobRepositoryFactoryBean;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.convert.support.ConfigurableConversionService;
@@ -61,8 +62,7 @@ import org.springframework.util.Assert;
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @since 2.0
* @deprecated Since 6.0 and scheduled for removal in 6.2 in favor of using
* {@link JdbcJobExplorerFactoryBean}.
* @deprecated since 6.0 in favor of {@link JdbcJobRepositoryFactoryBean}. Scheduled for removal in 6.2 or later.
*/
@Deprecated(since = "6.0", forRemoval = true)
public class JobExplorerFactoryBean extends AbstractJobExplorerFactoryBean implements InitializingBean {

View File

@@ -23,6 +23,7 @@ import org.springframework.batch.core.repository.dao.mongodb.MongoExecutionConte
import org.springframework.batch.core.repository.dao.mongodb.MongoJobExecutionDao;
import org.springframework.batch.core.repository.dao.mongodb.MongoJobInstanceDao;
import org.springframework.batch.core.repository.dao.mongodb.MongoStepExecutionDao;
import org.springframework.batch.core.repository.support.MongoJobRepositoryFactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.data.mongodb.core.MongoOperations;
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
@@ -38,7 +39,10 @@ import org.springframework.util.Assert;
*
* @author Mahmoud Ben Hassine
* @since 5.2.0
*
* @deprecated since 6.0 in favor of {@link MongoJobRepositoryFactoryBean}. Scheduled for removal in 6.2 or later.
*/
@Deprecated(since = "6.0", forRemoval = true)
public class MongoJobExplorerFactoryBean extends AbstractJobExplorerFactoryBean implements InitializingBean {
private MongoOperations mongoOperations;

View File

@@ -26,6 +26,7 @@ import org.springframework.batch.core.repository.dao.ExecutionContextDao;
import org.springframework.batch.core.repository.dao.JobExecutionDao;
import org.springframework.batch.core.repository.dao.JobInstanceDao;
import org.springframework.batch.core.repository.dao.StepExecutionDao;
import org.springframework.batch.core.repository.support.SimpleJobRepository;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.lang.Nullable;
@@ -47,7 +48,10 @@ import java.util.Set;
* @see JobExecutionDao
* @see StepExecutionDao
* @since 2.0
*
* @deprecated since 6.0 in favor of {@link SimpleJobRepository}. Scheduled for removal in 6.2 or later.
*/
@Deprecated(since = "6.0", forRemoval = true)
public class SimpleJobExplorer implements JobExplorer {
protected JobInstanceDao jobInstanceDao;

View File

@@ -44,7 +44,10 @@ import org.springframework.util.Assert;
* @author Dave Syer
* @author Mahmoud Ben Hassine
* @see CompletionPolicy
*
* @deprecated since 6.0 with no replacement. Scheduled for removal in 6.2 or later.
*/
@Deprecated(since = "6.0", forRemoval = true)
public class StepExecutionSimpleCompletionPolicy implements StepExecutionListener, CompletionPolicy {
private CompletionPolicy delegate;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2006-2023 the original author or authors.
* Copyright 2006-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.
@@ -32,7 +32,10 @@ import org.springframework.util.StringUtils;
* @author Lucas Ward
* @author Dave Syer
* @author Mahmoud Ben Hassine
*
* @deprecated since 6.0 with no replacement. Scheduled for removal in 6.2 or later.
*/
@Deprecated(since = "6.0", forRemoval = true)
public final class PropertiesConverter {
private static final String LINE_SEPARATOR = "\n";