# 8.1.2　配置流程注册表

流程注册表（flow registry）的工作是加载流程定义并让流程执行器能够使用它们。我们可以在 Spring 中使用 `<flow:flow-registry>` 配置流程注册表，如下所示：

```markup
<flow:flow-registry id="flowRegistry" base-path="/WEB-INF/flows">
  <flow:flow-location-pattern value="*-flow.xml" />
</flow:flow-registry>
```

在这里的声明中，流程注册表会在 `/WEB-INF/flows` 目录下查找流程定义，这是通过 base-path 属性指明的。依据 `<flow:flow-location-pattern>` 元素的值，任何文件名以 `-flow.xml` 结尾的 XML 文件都将视为流程定义。

所有的流程都是通过其 ID 来进行引用的。这里我们使用了 `<flow:flow-location-pattern>` 元素，流程的 ID 就是相对于 base-path 的路径 —— 或者双星号所代表的路径。图 8.1 展示了示例中的流程 ID 是如何计算的。

![图 8.1 在使用流程定位模式的时候，流程定义文件相对于基本路径的路径将被用作流程的 ID](/files/-LnG8lM9IR0RAve6p-Ir)

作为另一种方式，我们可以去除 base-path 属性，而显式声明流程定义文件的位置：

```markup
<flow:flow-registry id="flowRegistry">
  <flow:flow-location-pattern path="/WEB-INF/flows/springpizza.xml" />
</flow:flow-registry>
```

在这里，使用了而不是，path 属性直接指明了 `/WEB-INF/flows/springpizza.xml` 作为流程定义。当我们这样配置的话，流程的 ID 是从流程定义文件的文件名中获得的，在这里就是 springpizza。

如果你希望更显式地指定流程 ID，那你可以通过元素的 id 属性来进行设置。例如，要将 pizza 作为流程 ID，可以像这样配置：

```markup
<flow:flow-registry id="flowRegistry">
  <flow:flow-location id="pizza" path="/WEB-INF/flows/springpizza.xml" />
</flow:flow-registry>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://potoyang.gitbook.io/spring-in-action-v4/untitled-2/untitled-4/untitled-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
