# 84.2 改变AuthenticationManager并添加用户账号

如果你提供了一个`AuthenticationManager`、`AuthenticationProvider`、`UserDetailsService`类型的`@Bean`，那么默认的用于`InMemoryUserDetailsManager`的`@Bean`就不会被创建了，所以你可以获得Spring Security可用的全部特性（比如，[不同的认证选项](https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#jc-authentication)）。

添加用户帐户的最简单方法是提供你自己的`UserDetailsService` bean。


---

# 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://jack80342.gitbook.io/spring-boot/ix.-how-to-guides/84.-security/84.2-change-the-authenticationmanager-and-add-user-accounts.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.
