LoadTimeWeaver被Spring用來動態的轉換類,在它們被加載到JVM時。java
將@EnableLoadTimeWeaving添加到@Configuartion類中的一個來開啓加載時編織:code
@Configuration @EnableLoadTimeWeaving public class AppConfig { }
XML配置使用context:load-time-weaver元素:it
<beans> <context:load-time-weaver/> </beans>
一旦ApplicationContext被如此配置。任何ApplicationContext中的bean能夠實現LoadTimeWeaverAware,所以會接收到一個加載時編織實例的引用。這在Spring的JPA支持中很是有用,JPA類的轉換須要加載時編織。更多的信息請查詢LocalContainerEntityManagerFactoryBean javadoc。更多的AspectJ加載時編織知識能夠查看「Load-time weaving with AspectJ in the Spring Framework」。io