> For the complete documentation index, see [llms.txt](https://docs.flydean.com/spring-framework-documentation5/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flydean.com/spring-framework-documentation5/core-technologies/1.the-ioc-container/1.14registering-a-loadtimeweaver.md).

# 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。
