user3304825
user3304825

Reputation: 107

Why is my spring.datasource configuration not being picked up as expected

I have a batch job which runs perfectly well in standalone mode. I converted the same to a spring xd batch job. I am using spring xd version 1.0.0.M5. Some issues I face:

(i) I do not want to use hsqldb as my spring.datasource. I wanted to switch to mysql. In order to do so I updated the xd-config.yml file to reflect the same. It did not work. I added a snippet (application.yml) to my job config folder with the relevant datasource information did not work. I set the spring.datasource related environment variables on the command line. It works. Q: Is there a way to have mysql be picked as the profile such that the relevant metadata is picked either from the application.yml snippet or the xd-config.yml snippet without me having to set the environment variable manually?

Upvotes: 0

Views: 823

Answers (1)

Thomas Risberg
Thomas Risberg

Reputation: 976

The database configuration is still a work-in-progress. The goal for M6 is to have what you specify in xd-config.yml to control both the Spring Batch repository tables and the default for your batch jobs using JDBC.

In M5 there are separate settings to control this. The Spring Batch repository uses what is in config/xd-config.yml while the batch jobs you launch depend on config/batch-jdbc.properties. To use MySQL for both I changed:

config/xd-config.yml

#Config for use with MySQL - uncomment and edit with relevant values for your environment
spring:
  datasource:
    url: jdbc:mysql://localhost:3306/xd
    username: spring
    password: password
    driverClassName: com.mysql.jdbc.Driver
  profiles:
    active: default,mysql

config/batch-jdbc.properties

# Setting for the JDBC batch import job module

url=jdbc:mysql://localhost:3306/xd
username=spring
password=password
driverClass=com.mysql.jdbc.Driver

# Whether to initialize the database on job creation, and the script to
# run to do so if initializeDatabase is true.
initializeDatabase=false
initializerScript=init_batch_import.sql

Upvotes: 1

Related Questions