【问题标题】:Jersey2 Spring Tomcat load time weaver not workingJersey2 Spring Tomcat加载时间编织器不起作用
【发布时间】:2015-07-28 10:16:16
【问题描述】:

我在带有 spring 的 JAX-RS (Jersey2) 应用程序中使用休眠作为 JPA 提供程序。 我正在尝试在 JPA 实体中自动装配一些业务服务。我已经在 context.xml 中声明了一个加载器类

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

并将 spring-instrument.tomcat.4.1.17.jar 复制到 tomcat/libs

我也加了:

<context:load-time-weaver/>

到我的 applicationContext.xml

aop.xml 位于 resources/META-INF/aop.xml 下:

<!DOCTYPE aspectj PUBLIC
        "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">
<aspectj>
    <weaver options="-verbose -showWeaveInfo -XmessageHandlerClass:org.springframework.aop.aspectj.AspectJWeaverMessageHandler">
        <include within="com.appolica.server.musyme.*"/>
    </weaver>

</aspectj>

我已经尝试了 web 3.0 和 2.5 的配置。还有tomcat 8+和7+。

实体类使用@Configurable注解。

我在日志中得到的唯一内容是

Using a reflective load-time weaver for class loader: org.springframework.instrument.classloading.tomcat.TomcatInstrumentableClassLoader

我拥有所有可能的 aspectj 和 spring aop 依赖项:

compile 'org.aspectj:aspectjrt:1.8.6'
compile 'org.aspectj:aspectjweaver:1.8.6'
runtime 'org.aspectj:aspectjweaver:1.8.6'

compile 'org.springframework:spring-aspects:4.1.7.RELEASE'
compile "cglib:cglib:2.2"

compile "org.springframework:spring-aop:4.1.7.RELEASE"

compile 'org.springframework:spring-instrument-tomcat:4.1.7.RELEASE'
compile 'org.springframework:spring-instrument:4.1.7.RELEASE'

我真的很绝望,因为我已经尝试了所有我能想到/在互联网上找到的东西,而且服务永远不会自动连接。

【问题讨论】:

    标签: spring hibernate tomcat aspectj jersey-2.0


    【解决方案1】:

    我猜想有更多关于您的配置文件和代码的详细信息.. 但只有这个.. 请问您是否有

    <context:component-scan base-package="..... "/>
    

    在您的 applicationContext.xml 文件中?

    【讨论】:

    • 是的,
    • Tomcat 中存在关于 Time Weave 负载的文档问题。这取决于您的Tomcat版本是否可以工作。据我阅读的最新文档建议不要使用 Spring Instrument 并使用 Tomcat 8 中的那些。
    • Here a link to the issue下面的文字好像更清楚了...Note: The InstrumentableClassLoader mentioned in SPR-10788 does not exist neither in Tomcat 7.0.52 nor its current 7.0.x trunk (http://svn.apache.org/repos/asf/tomcat/tc7.0.x/trunk) but only in the main trunk (http://svn.apache.org/repos/asf/tomcat/trunk).
    • 我没有尝试在高于 7.0.52-1ubuntu 的版本中配置它......但在你的情况下,我将直接使用 Tomcat 8 并使用那里的功能。 as reference
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-10
    相关资源
    最近更新 更多