Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring Boot,@Configurable LoadTimeWeaving,Tomcat 8-IllegalStateException_Spring_Tomcat_Spring Boot_Spring Transactions_Spring Aspects - Fatal编程技术网

Spring Boot,@Configurable LoadTimeWeaving,Tomcat 8-IllegalStateException

Spring Boot,@Configurable LoadTimeWeaving,Tomcat 8-IllegalStateException,spring,tomcat,spring-boot,spring-transactions,spring-aspects,Spring,Tomcat,Spring Boot,Spring Transactions,Spring Aspects,在我的Spring Boot 1.3.3、Tomcat 8(嵌入式用于开发,独立用于生产)应用程序中,我将从Spring代理事务模式转移到AspectJ事务 我添加了以下应用程序配置: @EnableAsync @ComponentScan("com.example") @EntityScan("com.example") @EnableJpaRepositories("com.example") @EnableTransactionManagement(mode=AdviceMode.ASPE

在我的Spring Boot 1.3.3、Tomcat 8(嵌入式用于开发,独立用于生产)应用程序中,我将从Spring代理事务模式转移到AspectJ事务

我添加了以下应用程序配置:

@EnableAsync
@ComponentScan("com.example")
@EntityScan("com.example")
@EnableJpaRepositories("com.example")
@EnableTransactionManagement(mode=AdviceMode.ASPECTJ)
@EnableLoadTimeWeaving(aspectjWeaving=AspectJWeaving.ENABLED)
@Configuration
public class ApplicationConfiguration implements LoadTimeWeavingConfigurer {

    @Override
    public LoadTimeWeaver getLoadTimeWeaver() {
        return new ReflectiveLoadTimeWeaver();
    }

}
但是在嵌入式Tomcat 8上启动应用程序期间(不要在独立的Tomcat上测试),我遇到了以下异常:

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.instrument.classloading.LoadTimeWeaver]: Factory method 'loadTimeWeaver' threw exception; nested exception is java.lang.IllegalStateException: ClassLoader [sun.misc.Launcher$AppClassLoader] does NOT provide an 'addTransformer(ClassFileTransformer)' method.
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
    ... 18 common frames omitted
Caused by: java.lang.IllegalStateException: ClassLoader [sun.misc.Launcher$AppClassLoader] does NOT provide an 'addTransformer(ClassFileTransformer)' method.

我的配置中有什么错误/缺失,以及如何解决这个问题?

我过去也看到过,我相信您需要使用java代理运行应用程序,以便使用嵌入式tomcat实现加载时编织。准备好aspectjweaver和spring instrument JAR,然后尝试使用以下工具启动应用程序:

java -javaagent:path/to/aspectjweaver-1.8.2.jar -javaagent:path/to/spring-instrument.jar -jar path/to/your/app.jar

我也犯了同样的错误