how to setup load-time weaving with Spring and Tomcat WITHOUT using the -javaagent on the command line

后端 未结 3 1314
走了就别回头了
走了就别回头了 2021-01-12 14:40

I am using Spring 3.2.9, Tomcat 6.0.44

I am trying to configure my application\'s Spring instrumentation provider (e.g. spring-instrumentation.jar) for load-time wea

3条回答
  •  独厮守ぢ
    2021-01-12 15:30

    This is the code that I managed to use in order to removed the exception that you mentioned. Basically you have to implement the LoadTimeWeavingConfigurer and override the method getLoadTimeWeaver().

    @Configuration
    @ComponentScan(basePackages = "org.myproject")
    @EnableAspectJAutoProxy
    @EnableSpringConfigured
    @EnableLoadTimeWeaving(aspectjWeaving = EnableLoadTimeWeaving.AspectJWeaving.AUTODETECT)
    public class Config implements LoadTimeWeavingConfigurer {
    
        @Override
        public LoadTimeWeaver getLoadTimeWeaver() {
            return new ReflectiveLoadTimeWeaver();
        }
    
        @Bean
        public InstrumentationLoadTimeWeaver loadTimeWeaver()  throws Throwable {
            InstrumentationLoadTimeWeaver loadTimeWeaver = new InstrumentationLoadTimeWeaver();
            return loadTimeWeaver;
        }
    
    }
    

提交回复
热议问题