# 1.14 注册LoadTimeWeaver

当类被加载进入JVM的时候，LoadTimeWeaver被Spring用来进行动态类转换。

开启 load-time weaving， 可以添加@EnableLoadTimeWeaving到@Configuration类，如下所示：

```
@Configuration
@EnableLoadTimeWeaving
public class AppConfig {
}
```

或者可以使用XML的context:load-time-weaver，如下：

```
<beans>
    <context:load-time-weaver/>
</beans>
```

一旦为ApplicationContext配置好，该ApplicationContext中的任何bean都可以实现LoadTimeWeaverAware，从而接收对加载时weaver实例的引用。这在结合Spring的JPA支持时特别有用，因为在这种支持下，JPA类转换可能需要负载时间编织。有关详细信息，请参阅LocalContainerEntityManagerFactoryBean JavaDoc。有关Aspectj加载时编织的更多信息，请参见Spring框架中的Load Time Weaving with Aspectj。


---

# 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://docs.flydean.com/spring-framework-documentation5/core-technologies/1.the-ioc-container/1.14registering-a-loadtimeweaver.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.
