英文:
Spring batch job not creating tables
问题
以下是您要翻译的内容:
我有一个使用注释的配置类
元数据表已创建,但没有表前缀。
Initialize-schema始终是CUSTOM_
@Configuration
@Slf4j
@EnableBatchProcessing
public class BatchConfiguration {
@Autowired
private JobParametersValidator jobParametersValidator;
@Value("${spring.datasource.url}")
private String postgresUrl;
@Value("${spring.datasource.username}")
private String postgresUserName;
@Value("${spring.datasource.password}")
private String postgresPassword;
private String postgresSchema = "public";
@Bean("dataSource")
@Primary
public DataSource dataSource() {
HikariDataSource hikariDataSource = new HikariDataSource();
hikariDataSource.setJdbcUrl(this.postgresUrl);
hikariDataSource.setUsername(this.postgresUserName);
hikariDataSource.setPassword(this.postgresPassword);
hikariDataSource.setSchema(this.postgresSchema);
return hikariDataSource;
}
@Bean
public JpaTransactionManager transactionManager(){
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setDataSource(dataSource());
return transactionManager;
}
@Bean
public Job...
}
我的application.yml如下:
spring:
application:
name: ${APPLICATION_NAME}
batch:
jdbc:
initialize-schema: ALWAYS
table-prefix: CUSTOM_
job:
enabled: false
我缺少什么来初始化带有正确表前缀的架构
库:
spring-boot-starter-batch:3.0.5
它包括spring-batch-core:5.0.1
英文:
I have a configuration class annotated with
The metadata tables are getting created but without table prefix.
Initialize-schema is ALWAYS and table-prefix is CUSTOM_
@Configuration
@Slf4j
@EnableBatchProcessing
public class BatchConfiguration {
@Autowired
private JobParametersValidator jobParametersValidator;
@Value("${spring.datasource.url}")
private String postgresUrl;
@Value("${spring.datasource.username}")
private String postgresUserName;
@Value("${spring.datasource.password}")
private String postgresPassword;
private String postgresSchema = "public";
@Bean("dataSource")
@Primary
public DataSource dataSource() {
HikariDataSource hikariDataSource = new HikariDataSource();
hikariDataSource.setJdbcUrl(this.postgresUrl);
hikariDataSource.setUsername(this.postgresUserName);
hikariDataSource.setPassword(this.postgresPassword);
hikariDataSource.setSchema(this.postgresSchema);
return hikariDataSource;
}
@Bean
public JpaTransactionManager transactionManager(){
JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setDataSource(dataSource());
return transactionManager;
}
@Bean
public Job...
}
My application.yml looks like:
spring:
application:
name: ${APPLICATION_NAME}
batch:
jdbc:
initialize-schema: ALWAYS
table-prefix: CUSTOM_
job:
enabled: false
What am I missing to initialize the schema with correct table prefix
libraries:
spring-boot-starter-batch:3.0.5
It comprises of spring-batch-core:5.0.1
答案1
得分: 2
使用Spring Boot 3,当您添加@EnableBatchProcessing
时,Spring Batch的自动配置(元数据表创建、启动时作业的启动等)将被禁用。因此,您已配置的spring.batch.*
属性不会产生任何效果。
这在Spring Boot 3的迁移指南中有提到。
英文:
With Spring Boot 3, when you add @EnableBatchProcessing
, the auto-configuration of Spring Batch (meta-data tables creation, launching of jobs at startup, etc) will back off. As a result, the spring.batch.*
properties that you have configured do not have any effect.
This is mentioned in the migration guide of Spring Boot 3.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论