# 6.3. 配置类

Spring Boot 支持基于 Java 的配置。尽管可以通过XML 源使用`SpringApplication`，但我们通常建议您的主要源是单个`@Configuration`类。通常，定义`main`方法的类是作为主要`@Configuration`类的良好候选者。

> 互联网上已经发布了许多使用 XML 配置的 Spring 配置示例。如果可能，请始终尝试使用等效的基于 Java 的配置。搜索`Enable*`注释可能是一个很好的起点。

**6.3.1. 导入附加配置类**

您无需将所有`@Configuration`内容都放入一个类中。`@Import`注释可用于导入其他配置类。或者，您可以使用`@ComponentScan`自动获取所有 Spring 组件，包括`@Configuration`类。

**6.3.2. 导入 XML 配置**

如果您绝对必须使用基于 XML 的配置，我们建议您仍然从`@Configuration`类开始。然后，您可以使用`@ImportResource`注释来加载 XML 配置文件。


---

# 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://doc.shiker.tech/spring-boot-can-kao-wen-dang/6.-shi-yong-spring-boot-jin-xing-kai-fa/6.3.-pei-zhi-lei.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.
