如果缺少 hibernate 依赖项,方法 org.postgresql.jdbc

我为 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.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();


    }


叮当猫咪
浏览 111回答 1
1回答

繁花不似锦

这是一个 Hibernate问题。如果您使用的是 Spring Boot 最新版本,您可以 在2.0.x此处查看,但此问题已在5.4.0.CR1上修复,那么您需要添加该依赖项,或者如果可能,请添加最新版本:2.1.xHibernate 5.3.10.finalHibernate 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这些版本的此问题已修复。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java