Spring Boot Batch ResourcelessTransactionManager DataSourceProperties$DataSourceBeanCreationException

后端 未结 2 1908
北荒
北荒 2020-12-12 05:52

I\'m trying to setup a spring boot batch project that uses a ResourcelessTransactionManager transaction manager using Java Configuration, but I\'m having no luc

相关标签:
2条回答
  • 2020-12-12 06:04

    Your problem seem to be no data source available in your configuration. Spring Batch needs database so persist its state.

    Spring Boot can automatically configure in memory DB if you have some on classpath. Example application you are referring to has HSQL included in POM here: https://github.com/spring-projects/spring-boot/blob/v1.4.0.RELEASE/spring-boot-samples/spring-boot-sample-batch/pom.xml#L26

    So to fix your problem, define access to your Database.

    0 讨论(0)
  • 2020-12-12 06:05

    Below are some basic spring boot properties to set up data sources. By looking at driver class , boot can infer your db type and can auto create DataSource bean.

    spring.datasource.driver-class-name
    spring.datasource.url
    spring.datasource.username
    spring.datasource.password
    spring.datasource.tomcat.max-active
    spring.datasource.tomcat.initialSize
    spring.datasource.tomcat.maxIdle
    

    Last three properties are for setting up connection pools in container. Explicit DataSource information is missing and no in-memory database is provided in classpath.

    Fix issue by explicitly providing entries in application.properties or by including in-memory db ( H2 , HSQL etc ) in class path.

    Your configuration looks OK for not using any data sources ( i.e. if you have configured ResourcelessTransactionManager & MapJobRepository ) as long as you don't use EnableAutoConfiguration but your stack trace indicates usage of Boot with EnableAutoConfiguration.

    I guess, selective disabling of data source is not allowed, see question

    EDIT: I was able to fix error in your code by adding @SpringBootApplication(exclude={DataSource.class,DataSourceAutoConfiguration.class})

    Logs dumped this - after bean creation process,

    Exclusions:

    org.apache.tomcat.jdbc.pool.DataSource
    
    org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
    
    0 讨论(0)
提交回复
热议问题