Spring Boot Batch ResourcelessTransactionManager DataSourceProperties$DataSourceBeanCreationException

邮差的信 提交于 2019-11-28 14:39:17
Sabir Khan

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!