我为 spring batch 创建了一个小的 hello world 项目:构建.gradle:buildscript { repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.6.RELEASE") }}apply plugin: 'java'apply plugin: 'eclipse'apply plugin: 'idea'apply plugin: 'org.springframework.boot'apply plugin: 'io.spring.dependency-management'bootJar { baseName = 'gs-batch-processing' version = '0.1.0'}repositories { mavenCentral()}sourceCompatibility = 1.8targetCompatibility = 1.8dependencies { compile("org.springframework.boot:spring-boot-starter-batch") compile("org.postgresql:postgresql") compile("org.springframework.boot:spring-boot-starter-data-jpa") //to fix exception on startup //compile('org.hibernate:hibernate-core:5.4.2.Final') testCompile("junit:junit")}配置:@Configuration@EnableBatchProcessingpublic class BatchConfiguration { @Autowired public JobBuilderFactory jobBuilderFactory; @Autowired public StepBuilderFactory stepBuilderFactory; @Autowired private DbPersonWriter dbPersonWriter; @Autowired private ToLowerCasePersonProcessor toLowerCasePersonProcessor; @Value("${app.users-location}") Resource csvResource; @Bean public Job job() { return jobBuilderFactory.get("myJob") .incrementer(new RunIdIncrementer()) .flow(csvToDataBaseStep()) .end() .build(); } private Step csvToDataBaseStep() { return stepBuilderFactory.get("csvToDatabaseStep") .<Person, Person>chunk(100) .reader(csvPersonReader()) .processor(toLowerCasePersonProcessor) .writer(dbPersonWriter) .build(); }
1 回答
繁花不似锦
TA贡献1851条经验 获得超4个赞
这是一个 Hibernate问题。如果您使用的是 Spring Boot 最新版本,您可以 在2.0.x
此处查看,但此问题已在5.4.0.CR1上修复,那么您需要添加该依赖项,或者如果可能,请添加最新版本:2.1.x
Hibernate 5.3.10.final
Hibernate version
对于摇篮:
compile('org.hibernate:hibernate-core:5.4.2.Final')
对于胃:
<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>5.4.2.Final</version> </dependency>
更新“弹簧启动 2.2.0.M(1-4)”
此外Spring boot v2.2.0.Mx
,现在还包括Hibernate v5.4.x
这些版本的此问题已修复。
添加回答
举报
0/150
提交
取消