1.14. Registering a LoadTimeWeaver

上一节 1.13. Environment Abstraction

目录

下一节 1.15. Additional Capabilities of the ApplicationContext

1.14. Registering a LoadTimeWeaver

1.1.4. 注册一个LoadTimeWeaver

The LoadTimeWeaver is used by Spring to dynamically transform classes as they are loaded into the Java virtual machine (JVM).

当类装入Java虚拟机(JVM)时,Spring使用LoadTimeWeaver动态地转换类。

To enable load-time weaving, you can add the @EnableLoadTimeWeaving to one of your @Configuration classes, as the following example shows:

要启用load-time weaving,可以将@EnableLoadTimeWeaving添加到一个@Configuration类中,如下面的示例所示:

@Configuration
@EnableLoadTimeWeaving
public class AppConfig {
}

Alternatively, for XML configuration, you can use the context:load-time-weaver element:

或者,对于XML配置,您可以使用context:load-time-weaver元素:

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

Once configured for the ApplicationContext, any bean within that ApplicationContext may implement LoadTimeWeaverAware, thereby receiving a reference to the load-time weaver instance. This is particularly useful in combination with Spring’s JPA support where load-time weaving may be necessary for JPA class transformation. Consult the LocalContainerEntityManagerFactoryBean javadoc for more detail. For more on AspectJ load-time weaving, see Load-time Weaving with AspectJ in the Spring Framework.

一旦为ApplicationContext配置好,该ApplicationContext中的
任何bean都可以实现LoadTimeWeaverAware,从而接收到 
load-time weaver 实例的引用。
这在与Spring的JPA支持相结合时特别有用,其中 load-time weaving 
对于JPA类转换可能是必要的。
更多细节请参考LocalContainerEntityManagerFactoryBean 的 javadoc。
有关AspectJ装入时编织的更多信息,请参见章节  
Load-time Weaving with AspectJ in the Spring Framework 。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值