@@ -6,6 +6,8 @@ of the various persisted domain objects within Spring Batch, such as `JobExecuti
66It is required by many of the major framework features, such as the `JobOperator`,
77`Job`, and `Step`.
88
9+ == Configuring a JDBC JobRepository
10+
911[tabs]
1012====
1113Java::
@@ -68,6 +70,29 @@ The `max-varchar-length` defaults to `2500`, which is the length of the long
6870`VARCHAR` columns in the xref:schema-appendix.adoc#metaDataSchemaOverview[sample schema scripts].
6971====
7072
73+ == Configuring a MongoDB JobRepository
74+
75+ Similar to the JDBC-based `JobRepository`, the MongoDB-based `JobRepository` requires some collections
76+ to store the batch metadata. These collections are defined in the `org/springframework/batch/core/schema-mongodb.jsonl`
77+ of the `spring-batch-core` jar. As with the JDBC-based `JobRepository`, you need to create these collections
78+ in your MongoDB database before running any job.
79+
80+ Moreover, since it is https://www.mongodb.com/docs/manual/core/dot-dollar-considerations/[not recommended] to use `.` in
81+ field names in MongoDB documents, you need to customize the `MongoTemplate` used by the `MongoJobRepositoryFactoryBean`
82+ to replace `.` with another character (for example, `_`) in the field names. You can do this by customizing the `MappingMongoConverter`
83+ used by the `MongoTemplate`. The following example shows how to do this in Java configuration:
84+
85+ .Java Configuration
86+ [source, java]
87+ ----
88+ @Bean
89+ public MongoTemplate mongoTemplate(MongoDatabaseFactory mongoDatabaseFactory) {
90+ MongoTemplate template = new MongoTemplate(mongoDatabaseFactory);
91+ MappingMongoConverter converter = (MappingMongoConverter) template.getConverter();
92+ converter.setMapKeyDotReplacement("_");
93+ return template;
94+ }
95+ ----
7196
7297[[txConfigForJobRepository]]
7398== Transaction Configuration for the JobRepository
0 commit comments