gpt4 book ai didi

spring - Jersey2 Spring Tomcat 加载时间编织器不工作

转载 作者:行者123 更新时间:2023-11-28 23:30:04 25 4
gpt4 key购买 nike

我在带有 spring 的 JAX-RS (Jersey2) 应用程序中使用 hibernate 作为 JPA 提供程序。我正在尝试在 JPA 实体中 Autowiring 一些业务服务。我在 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'

我真的很绝望,因为我已经尝试了所有我能想到/在 Internet 上找到的方法,但这些服务从未 Autowiring 。

最佳答案

我猜你有更多关于你的配置文件和代码的细节..但只有这个..我能问一下你是否有

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

在您的applicationContext.xml 文件中?

关于spring - Jersey2 Spring Tomcat 加载时间编织器不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31673437/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com