0

我有一个批处理作业,它在独立模式下运行得非常好。我将其转换为 spring xd 批处理作业。我正在使用 spring xd 版本 1.0.0.M5。我面临的一些问题:

(i) 我不想使用 hsqldb 作为我的 spring.datasource。我想切换到mysql。为此,我更新了 xd-config.yml 文件以反映相同的内容。那没起效。我在我的作业配置文件夹中添加了一个片段(application.yml),其中相关的数据源信息不起作用。我在命令行设置了spring.datasource相关的环境变量。有用。问:有没有办法选择 mysql 作为配置文件,以便从 application.yml 片段或 xd-config.yml 片段中选择相关元数据,而无需手动设置环境变量?

4

1 回答 1

1

数据库配置仍在进行中。M6 的目标是让您在 xd-config.yml 中指定的内容来控制 Spring Batch 存储库表和使用 JDBC 的批处理作业的默认值。

在 M5 中有单独的设置来控制它。Spring Batch 存储库使用 config/xd-config.yml 中的内容,而您启动的批处理作业取决于 config/batch-jdbc.properties。为了对两者都使用 MySQL,我进行了更改:

配置/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

配置/批处理-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
于 2014-03-10T14:31:26.953 回答