Java 如果缺少hibernate依赖项,则尚未实现org.postgresql.jdbc.PgConnection.createClob()方法
我已经为spring batch创建了hello world小项目: build.gradle:Java 如果缺少hibernate依赖项,则尚未实现org.postgresql.jdbc.PgConnection.createClob()方法,java,spring-boot,spring-data-jpa,spring-data,spring-batch,Java,Spring Boot,Spring Data Jpa,Spring Data,Spring Batch,我已经为spring batch创建了hello world小项目: build.gradle: buildscript { repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.6.RELEASE") } } apply plugin: 'java' appl
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.8
targetCompatibility = 1.8
dependencies {
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
@EnableBatchProcessing
public 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();
}
还有更优雅的方式吗?我认为变通办法不是一个好的解决办法
附笔。
要使用源代码,您可以遵循这是一个Hibernate。
如果您使用的是从2.0.x
到2.1.x
包括Hibernate 5.3.10。最终版
您可以查看一下,但此问题已在Hibernate版本
5.4.0.CR1上解决。然后您需要添加该依赖项,或者如果可能的话,添加最新版本:
对于Gradle:
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>
对于Maven:
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>
org.hibernate
冬眠核心
5.4.2.最终版本
更新了“SPRING BOOT 2.2.0.M(1-4)”
另外,Spring boot v2.2.0.Mx现在包括了Hibernate v5.4.x版,这个问题在这些版本中得到了解决。没有,因为这是Hibernate的问题,所以你需要升级它,嗯。。。我使用最新的spring boot版本,据我所知,最新的spring boot版本不包括这个hibernate版本,您可以从spring boot版本2.1.0中查看一下,它包括hibernate版本5.3,因此我认为2.1.6不包括您可以查看添加的依赖项@Jonathan Johx你能补充一下答案吗?这将对未来的谷歌用户有所帮助,并将关闭我们的主题。我更新了我的答案,这在
SpringBoot2.2.0.M(1-4)
上得到了修复,所以这个问题应该在那些版本上得到修复。