簡體   English   中英

Apache Tomcat 8春季加載時間編織不適用於ContextLoaderListener加載的bean

[英]Apache Tomcat 8 spring load time weaving is not working for beans loaded by ContextLoaderListener

從tomcat 7 Java 7遷移到tomcat 8 Java 8時發生了問題。

在Tomcat 7中,加載時間編織是根據context.xml文件中指定的加載器類進行的

<Loader loaderClass="org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader"/> 

作為遷移的一部分,我們從context.xml中刪除了上面的加載程序類定義,並將應用程序部署到了tomcat8。

現在,加載時間編織僅適用於由調度程序servlet加載的bean,而ContextLoaderListener加載的applicationContext.xml中bean不起作用 請提供任何建議。

再次重復同樣的問題。

在啟動加載時編織之前,如何防止applicationContext.xml中的bean 加載

我試圖韋弗配置負載時沒有-javaagent選項是這可能嗎?

請注意下面給出的配置的重要部分

applicationContext.xml中

<aop:aspectj-autoproxy />
    <context:spring-configured />
    <context:load-time-weaver aspectj-weaving="autodetect"/>     
    <tx:annotation-driven transaction-manager="transactionManager" mode="aspectj"/>

    <bean id="mainContextLoadingService"
          class="com.riyaskt.trial.service.impl.MainContextLoadingServiceImpl" />  

調度員servlet.xml中

<context:component-scan base-package="com.riyaskt.trial" />  
    <mvc:annotation-driven/>
<bean id="sampleService"
          class="com.riyaskt.trial.service.impl.SampleServiceImpl"          
          p:dao-ref="sampleDao"/> 

在這兩個服務bean中(即applicationContext.xml中的mainContextLoadingService調度程序servlet中的 sampleService )。

正確編織sampleService

mainContextLoadingService 不會被加載時間編織器編織。

嘗試使用Spring Instrument Jar。 從此鏈接下載最新的4.2.3 jar。 在Eclipse中打開您的tomcat的打開啟動配置(在“ 服務器”選項卡中雙擊您的tomcat並單擊“ 打開啟動配置” )。 現在單擊Arguments選項卡,然后將以下行附加到VM參數

-javaagent:<Path to Spring Instrument jar you downloaded>

例如,例如,您下載了spring-instrument-4.2.3.RELEASE.jar並將其放置在D驅動器中,則javaagent參數將如下所示:

-javaagent:D:\spring-instrument-4.2.3.RELEASE.jar

使用Aspectj-weaving =“ autodetect”屬性,如果在類路徑上存在“ META-INF / aop.xml”資源,則默認情況下將激活AspectJ編織。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM