Java 找不到 org.aspectj.weaver.reflect.ReflectionWorld

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19047775/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 13:39:41  来源:igfitidea点击:

Cannot find org.aspectj.weaver.reflect.ReflectionWorld

javaeclipsespringhibernateaspectj

提问by Jo?o Sim?es

I'm setting a Spring 3.2.3 + Hibernate 4 project in Eclipse 4.3.

我正在 Eclipse 4.3 中设置 Spring 3.2.3 + Hibernate 4 项目。

When I add the code <tx:annotation-driven transaction-manager="transactionManager"/>to my context I start getting the following error in every single bean:

当我将代码添加<tx:annotation-driven transaction-manager="transactionManager"/>到我的上下文时,我开始在每个 bean 中收到以下错误:

Build path is incomplete. Cannot find class file for org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException

Now, I added both AspectJ Tools and Cglib dependencies to my project and the JARs are there, including the class it can't find. The application runs normally, and Spring is managing sessions and transactions successfully.

现在,我将 AspectJ 工具和 Cglib 依赖项添加到我的项目中,并且 JAR 文件在那里,包括它找不到的类。应用程序正常运行,Spring 正在成功管理会话和事务。

I've searched for a solution but every answers says the error occurs because the lack of JARs.

我已经搜索了一个解决方案,但每个答案都说由于缺少 JAR 而发生错误。

Does anyone knows what I'm missing (incompatible versions?) or is this an Eclipse bug?

有谁知道我缺少什么(不兼容的版本?)或者这是一个 Eclipse 错误?

Here is a print screen of the problem (every error you'll see is the one I indicated above).

这是问题的打印屏幕(您将看到的每个错误都是我上面指出的错误)。

enter image description here

在此处输入图片说明

Thanks in advance!

提前致谢!

采纳答案by Jo?o Sim?es

Ok, I finally found the solution to my problem!

好的,我终于找到了解决我的问题的方法!

When I installed the Spring Tools plugin it seems I forgot to check both "AspectJ Compiler" and "AspectJ Development Tools" from the plugin list. As soon as I installed and restarted the Eclipse, the errors disappeared.

当我安装 Spring Tools 插件时,似乎我忘了从插件列表中检查“AspectJ Compiler”和“AspectJ Development Tools”。一旦我安装并重新启动 Eclipse,错误就消失了。

Here's a print screen if someone interested:

如果有人感兴趣,这是一个打印屏幕:

enter image description here

在此处输入图片说明

回答by Pere

Maybe you're missing som aspectj libs?

也许你缺少一些aspectj库?

Try adding to your pom

尝试添加到你的 pom

<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjrt</artifactId>
    <version>1.7.3</version>    
</dependency>
<dependency>
    <groupId>org.aspectj</groupId>
    <artifactId>aspectjweaver</artifactId>
    <version>1.7.3</version>
</dependency>

回答by Daniel

Here's what worked for me:

以下是对我有用的内容:

  • I added to my POM.xml the dependencies Pere suggested in his answer:

    org.aspectj aspectjrt 1.7.3
    org.aspectj aspectjweaver 1.7.3

  • 我在 POM.xml 中添加了 Pere 在他的回答中建议的依赖项:

    org.aspectj aspectjrt 1.7.3
    org.aspectj aspectjweaver 1.7.3

Then I right clicked on my project's name in Project Explorer --> properties --> java build path --> Order and Export tab.

然后我在 Project Explorer --> properties --> java build path --> Order and Export 选项卡中右键单击我的项目名称。

In this tab I noticed that for some strange reason Maven Dependencies is no longer checked. I checked it, and after I applied the changes, the error mentioned in the question above disappeared.

在这个选项卡中,我注意到由于某种奇怪的原因 Maven Dependencies 不再被检查。我检查了一下,应用更改后,上面问题中提到的错误消失了。

回答by cgull

I had to add the Spring builder to my eclipse .project file to fix this issue

我不得不将 Spring builder 添加到我的 eclipse .project 文件中来解决这个问题

        <buildCommand>
        <name>org.springframework.ide.eclipse.core.springbuilder</name>
        <arguments>
        </arguments>
    </buildCommand>

回答by ZuberFowler

I received this same error message when copying xml code from an older project. I believe the relevant line in the <beansheader that was causing the problem was:
http://www.springframework.org/schema/tx/spring-tx-3.2.xsdas the project had been/was actually using the 4.0 libraries.

从旧项目复制 xml 代码时,我收到了同样的错误消息。我相信<beans导致问题的标题中的相关行是:
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd因为该项目实际上已经/正在使用 4.0 库。

To fix it I deleted the offending xml file, used right click to remove spring project nature (under spring tools), closed/reopened the project. Once the error was gone, I converted back to spring nature and then recreated the xml file with 3.2 properly changed to 4.0.

为了修复它,我删除了有问题的 xml 文件,使用右键单击删除 spring 项目性质(在 spring 工具下),关闭/重新打开项目。错误消失后,我转换回 spring 性质,然后将 3.2 正确更改为 4.0 重新创建 xml 文件。