【问题标题】:Spring XML NamespacesSpring XML 命名空间
【发布时间】:2012-01-06 12:32:43
【问题描述】:

我目前正在努力完成“Spring in Action”。从这些方面开始被卡住,我想知道是否有人能看到我的错误。 在我的 AppConfig.xml 中,我开始 bean-declaratiotn:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
                        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

运行应用程序,我得到以下异常:

Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [config/AppConfig.xml]; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice

定义可能有误?

任何帮助表示赞赏!

问候, 马库斯

【问题讨论】:

  • 这不是配置错误,而是缺少库错误。你在部署 aop 依赖吗?

标签: xml spring config


【解决方案1】:

确保您的项目中包含 spring-aop.jar、aopalliance.jar 或 aspectjtools-1.6.0.jar。该错误表明在您的类路径中找不到 Advice 类。它可以在我提到的两个 jar 之一中找到,具体取决于您使用的 Spring 版本。

http://forum.springsource.org/showthread.php?82282-ava-lang-ClassNotFoundException-org-aopalliance-aop-Advice

【讨论】:

  • 其实是缺少aspectjtools-1.6.0.jar,spring-distribution好像已经完成了。没有什么可以探索新语言的领域 8)
  • @Marcus Toepper 感谢更新,我编辑了答案以包含您的发现。
【解决方案2】:

在开始应用程序开发 Spring 3.0 版本时,我也遇到了同样的问题。

AOP 从 3.0 版本中移除。

因此,您需要明确下载并在您的类路径中包含这个特定的 jar { aopalliance-1.0.jar }。

这样就可以解决问题了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-05-26
    • 1970-01-01
    • 1970-01-01
    • 2014-11-10
    • 2015-08-30
    • 2013-07-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多