Java 无法解析 org.springframework.context.ApplicationContextAware 类型。它是从所需的 .class 文件间接引用的

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18811276/
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 11:15:43  来源:igfitidea点击:

The type org.springframework.context.ApplicationContextAware cannot be resolved. It is indirectly referenced from required .class files

javaspringspring-mvc

提问by Mohammad Parsa

Compiling the following code yields this error:

编译以下代码会产生此错误:

The type org.springframework.context.ApplicationContextAware cannot be resolved. It is indirectly referenced from required .class files (this error is for last line of code)

无法解析 org.springframework.context.ApplicationContextAware 类型。它是从所需的 .class 文件间接引用的(此错误针对最后一行代码)

I think I should add a .jar file in build path, but I don't know what is it?

我想我应该在构建路径中添加一个 .jar 文件,但我不知道它是什么?

CamelContext context = new DefaultCamelContext(); 
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(ActiveMQConnection.DEFAULT_BROKER_URL);
context.addComponent("test-jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));

采纳答案by Ravi Thapliyal

You need to add Spring Framework's

您需要添加Spring Framework

org.springframework.context-3.x.x.jar

to your project's build path. Depending on which third party library you're using it may have additional Spring dependencies and you would have to add those Spring jars too. You'd most likely need org.springframework.core-3.x.x.jartoo.

到您项目的构建路径。根据您使用的第三方库,它可能有额外的 Spring 依赖项,您也必须添加这些 Spring jar。你很可能也需要org.springframework.core-3.x.x.jar

Consult your direct dependencies' documentation to find out what its dependencies are.

请查阅您的直接依赖项的文档以了解其依赖项是什么。