【问题标题】:Cannot find the declaration of element 'beans' error occur when run jar运行jar时找不到元素'beans'错误的声明
【发布时间】:2014-02-21 15:46:20
【问题描述】:

我正在使用 Spring 3.0 和 我正在使用 eclipse IDE ,该项目是在 IDE 中找到的,但是当我生成 jar 文件时运行它。 发生错误 org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:来自类路径资源 [spring-beans.xml] 的 XML 文档中的第 13 行无效;嵌套异常是 org.xml.sax.SAXParseException;行号:13;列号:84; cvc-elt.1:找不到元素“beans”的声明。

这是我的 spring 配置文件

   <?xml version="1.0" encoding="UTF-8"?> 
     <beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
     xmlns:context="http://www.springframework.org/schema/context" 
     xmlns:tx="http://www.springframework.org/schema/tx"  
     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/tx  
        http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 
        http://www.springframework.org/schema/context  
        http://www.springframework.org/schema/context/spring-context-3.0.xsd">
    <context:annotation-config/> 
    <context:component-scan base-package="com.plyd.java"/>
  </beans>

我正在谷歌搜索该错误并在我的项目中测试解决方案,但不行。 代码可以在 IDE 中找到。但是当我生成可运行的 jar 并运行它时,会出现错误。 请给我一些建议谢谢。

【问题讨论】:

  • 您在 Eclipse 中使用的 JRE 是否与您在命令行中使用的相同?例如。两者是相同的供应商/版本,还是不同的版本,相同的供应商,还是不同的供应商?
  • @PaulGrime 是的,两个 JRE 都是一样的。

标签: java spring swing schema


【解决方案1】:

如果你使用的是 Eclipse,试试这个 导出 jar > 将所需的库复制到子文件夹中

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-07-05
    • 2015-02-09
    • 2015-12-19
    • 1970-01-01
    • 2012-04-28
    • 1970-01-01
    • 2015-08-11
    相关资源
    最近更新 更多