parent
d6818e96f5
commit
e0f59d8a74
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2015 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.
|
||||
|
|
@ -29,7 +29,6 @@ import org.springframework.batch.core.launch.JobLauncher;
|
|||
import org.springframework.batch.core.launch.support.SimpleJobLauncher;
|
||||
import org.springframework.batch.core.repository.JobRepository;
|
||||
import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.orm.jpa.JpaTransactionManager;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
@ -43,10 +42,12 @@ import org.springframework.util.StringUtils;
|
|||
* @author Andy Wilkinson
|
||||
*/
|
||||
@Component
|
||||
public class BasicBatchConfigurer implements BatchConfigurer {
|
||||
class BasicBatchConfigurer implements BatchConfigurer {
|
||||
|
||||
private static Log logger = LogFactory.getLog(BasicBatchConfigurer.class);
|
||||
|
||||
private final BatchProperties properties;
|
||||
|
||||
private final DataSource dataSource;
|
||||
|
||||
private final EntityManagerFactory entityManagerFactory;
|
||||
|
|
@ -59,15 +60,12 @@ public class BasicBatchConfigurer implements BatchConfigurer {
|
|||
|
||||
private JobExplorer jobExplorer;
|
||||
|
||||
@Autowired
|
||||
private BatchProperties properties;
|
||||
|
||||
/**
|
||||
* Create a new {@link BasicBatchConfigurer} instance.
|
||||
* @param dataSource the underlying data source
|
||||
*/
|
||||
public BasicBatchConfigurer(DataSource dataSource) {
|
||||
this(dataSource, null);
|
||||
public BasicBatchConfigurer(BatchProperties properties, DataSource dataSource) {
|
||||
this(properties, dataSource, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -75,8 +73,9 @@ public class BasicBatchConfigurer implements BatchConfigurer {
|
|||
* @param dataSource the underlying data source
|
||||
* @param entityManagerFactory the entity manager factory (or {@code null})
|
||||
*/
|
||||
public BasicBatchConfigurer(DataSource dataSource,
|
||||
public BasicBatchConfigurer(BatchProperties properties, DataSource dataSource,
|
||||
EntityManagerFactory entityManagerFactory) {
|
||||
this.properties = properties;
|
||||
this.entityManagerFactory = entityManagerFactory;
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2015 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.
|
||||
|
|
@ -55,6 +55,7 @@ import org.springframework.util.StringUtils;
|
|||
* JobRegistry.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Eddú Meléndez
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass({ JobLauncher.class, DataSource.class, JdbcOperations.class })
|
||||
|
|
@ -130,6 +131,9 @@ public class BatchAutoConfiguration {
|
|||
@Configuration
|
||||
protected static class JpaBatchConfiguration {
|
||||
|
||||
@Autowired
|
||||
private BatchProperties properties;
|
||||
|
||||
// The EntityManagerFactory may not be discoverable by type when this condition
|
||||
// is evaluated, so we need a well-known bean name. This is the one used by Spring
|
||||
// Boot in the JPA auto configuration.
|
||||
|
|
@ -137,13 +141,13 @@ public class BatchAutoConfiguration {
|
|||
@ConditionalOnBean(name = "entityManagerFactory")
|
||||
public BatchConfigurer jpaBatchConfigurer(DataSource dataSource,
|
||||
EntityManagerFactory entityManagerFactory) {
|
||||
return new BasicBatchConfigurer(dataSource, entityManagerFactory);
|
||||
return new BasicBatchConfigurer(this.properties, dataSource, entityManagerFactory);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(name = "entityManagerFactory")
|
||||
public BatchConfigurer basicBatchConfigurer(DataSource dataSource) {
|
||||
return new BasicBatchConfigurer(dataSource);
|
||||
return new BasicBatchConfigurer(this.properties, dataSource);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2015 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,6 +22,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
|||
* Configuration properties for Spring Batch.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Eddú Meléndez
|
||||
* @since 1.2.0
|
||||
*/
|
||||
@ConfigurationProperties("spring.batch")
|
||||
|
|
@ -35,6 +36,9 @@ public class BatchProperties {
|
|||
*/
|
||||
private String schema = DEFAULT_SCHEMA_LOCATION;
|
||||
|
||||
/**
|
||||
* Table prefix for all the batch meta-data tables.
|
||||
*/
|
||||
private String tablePrefix;
|
||||
|
||||
private final Initializer initializer = new Initializer();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2015 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.
|
||||
|
|
|
|||
|
|
@ -450,11 +450,12 @@ content into your application; rather pick only the properties that you need.
|
|||
spring.mail.default-encoding=UTF-8 # encoding to use for MimeMessages
|
||||
spring.mail.properties.*= # properties to set on the JavaMail session
|
||||
|
||||
# SPRING BATCH ({sc-spring-boot-autoconfigure}/batch/BatchDatabaseInitializer.{sc-ext}[BatchDatabaseInitializer])
|
||||
# SPRING BATCH ({sc-spring-boot-autoconfigure}/batch/BatchProperties.{sc-ext}[BatchProperties])
|
||||
spring.batch.job.names=job1,job2
|
||||
spring.batch.job.enabled=true
|
||||
spring.batch.initializer.enabled=true
|
||||
spring.batch.schema= # batch schema to load
|
||||
spring.batch.table-prefix= # table prefix for all the batch meta-data tables
|
||||
|
||||
# SPRING CACHE ({sc-spring-boot-autoconfigure}/cache/CacheProperties.{sc-ext}[CacheProperties])
|
||||
spring.cache.type= # generic, ehcache, hazelcast, jcache, redis, guava, simple, none
|
||||
|
|
|
|||
Loading…
Reference in New Issue