# 50.2 暴露端点

由于端点可能包含敏感信息，暴露它们要慎重。下面的表格展示了内建端点默认是否展示的情况：

| ID               | JMX | Web |
| ---------------- | --- | --- |
| `auditevents`    | Yes | No  |
| `beans`          | Yes | No  |
| `conditions`     | Yes | No  |
| `configprops`    | Yes | No  |
| `env`            | Yes | No  |
| `flyway`         | Yes | No  |
| `health`         | Yes | Yes |
| `heapdump`       | N/A | No  |
| `httptrace`      | Yes | No  |
| `info`           | Yes | Yes |
| `jolokia`        | N/A | No  |
| `logfile`        | N/A | No  |
| `loggers`        | Yes | No  |
| `liquibase`      | Yes | No  |
| `metrics`        | Yes | No  |
| `mappings`       | Yes | No  |
| `prometheus`     | N/A | No  |
| `scheduledtasks` | Yes | No  |
| `sessions`       | Yes | No  |
| `shutdown`       | Yes | No  |
| `threaddump`     | Yes | No  |

使用下面技术特定的`include`和`exclude`属性，改变端点的暴露状况：

| 属性                                          | 默认             |
| ------------------------------------------- | -------------- |
| `management.endpoints.jmx.exposure.exclude` |                |
| `management.endpoints.jmx.exposure.include` | `*`            |
| `management.endpoints.web.exposure.exclude` |                |
| `management.endpoints.web.exposure.include` | `info, health` |

`include`属性列出了暴露的端点ID。`exclude`属性列出了不应当暴露的端点ID。`exclude`属性优先于`include`属性。`include`和`exclude`属性都可以使用端点ID列表配置。

例如，为了停止暴露所有JMX端点，只暴露`health`和`info`端点，使用下面的属性：

```
management.endpoints.jmx.exposure.include=health,info
```

`*`可以用于选择所有端点。例如，为了暴露所有HTTP端点，但是不暴露`env`和`beans`端点，使用下面的属性：

```
management.endpoints.web.exposure.include=*
management.endpoints.web.exposure.exclude=env,beans
```

**注** 如果你的应用公开暴露，我们强烈推荐你[加密端点](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-endpoints-security).

**注** 如果你想实现自己的何时暴露端点的策略，你可以注册一个`EndpointFilter` bean。
