Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 弹簧框架配置问题“;元素上下文的前缀上下文:注释配置未绑定";_Java_Xml_Spring - Fatal编程技术网

Java 弹簧框架配置问题“;元素上下文的前缀上下文:注释配置未绑定";

Java 弹簧框架配置问题“;元素上下文的前缀上下文:注释配置未绑定";,java,xml,spring,Java,Xml,Spring,我有一个奇怪的问题,我似乎找不到。我与其他服务器一起工作时没有问题,但我似乎无法让它正常工作。我看到的与我的问题最接近的帖子是这个帖子 所有其他的都只是因为前缀不在xml文件中。我希望有人能给我指出正确的方向 Spring XML文件: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://ww

我有一个奇怪的问题,我似乎找不到。我与其他服务器一起工作时没有问题,但我似乎无法让它正常工作。我看到的与我的问题最接近的帖子是这个帖子

所有其他的都只是因为前缀不在xml文件中。我希望有人能给我指出正确的方向

Spring XML文件:

<?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:dwr="http://www.directwebremoting.org/schema/spring-dwr"
  xmlns:mongo="http://www.springframework.org/schema/data/mongo"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  http://www.springframework.org/schema/context
  http://www.springframework.org/schema/context/spring-context-3.0.xsd
   http://www.springframework.org/schema/data/mongo
    http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
    http://www.directwebremoting.org/schema/spring-dwr
    http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd">

    <context:annotation-config/>
谢谢你的帮助。让我知道我还能提供什么


谢谢

以下内容适合我:

test.xml

<?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:dwr="http://www.directwebremoting.org/schema/spring-dwr"
  xmlns:mongo="http://www.springframework.org/schema/data/mongo"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/data/mongo
    http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
    http://www.directwebremoting.org/schema/spring-dwr
    http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd">

    <context:annotation-config/>

</beans>
你能看看这是否适合你吗?在类路径中需要以下库:commons日志、spring asm、spring bean、spring上下文、spring核心和spring表达式


请让我知道它是否有效。如果没有,请发布完整的堆栈跟踪。最后,我使用Spring3.1.1实现上述功能

我也遇到了同样的问题,直到我意识到
beans
标记属性
xmlns:context
丢失。只是添加了以下几行

xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
...."
然后重建项目


当SpringXML文件中缺少
xmlns:context
时,就会出现此错误。所以加上它。您的beans头应该如下所示-

<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-2.5.xsd" >

    <context:annotation-config />
    <context:component-scan base-package="controller" />

</beans>

我遇到了同样的问题,但我可以通过移动解决它


从applicationContext.xml到spring-servlet.xml,并在spring-servlet.xml中添加xmlns:context,这非常奇怪。。。它看起来确实应该起作用。您的XML文件是否明确编码为UTF-8?您使用的是什么版本的Java?使用:Java版本“1.6.0_45”抱歉,继续按enter键并发布。如何验证文本文件的UTF-8编码。使用文件只是告诉我它是XML。使用OpenOffice打开时似乎没有问题,将其作为UTF-8文档打开。对不起,我不知道另一种测试方法。thanksHow你正在发布你的Spring应用程序吗?不确定你在这里寻找什么。这将使用Jetty,我有一个用于启动服务器的类。Spring从那里启动,然后有一个web.xml文件来配置servlet等。是的,这就是我想知道的。如果您在web应用程序或其他应用程序中运行。我将发布一个答案,这更像是一个问题。看起来这是成功的。这是否意味着我的代码中一定有其他错误或其他什么?如果真是这样的话,你知道这与什么有关吗?如果不看所有的东西,很难说出来。作为初学者,我建议为您的开发安装一个IDE(例如Eclipse、IDEA、Netbeans)。完成此操作后,安装/设置适当的插件/扩展以从IDE运行Jetty。这将为您节省大量时间,并有助于解决此问题。我正在使用EclipseKewl我将看看能从Eclipse中找到什么来启动Jetty。非常感谢。这是解决我的问题的方法。这是我的错,我从GIT运行了两个副本,并且我更新了错误的XML文件,所以它不能正常工作。一旦修复了正确的配置文件,它就工作了。仅供参考,我确实找到了其他关于名称空间顺序的文章。
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
...."
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://www.springframework.org/schema/beans"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-2.5.xsd" >

    <context:annotation-config />
    <context:component-scan base-package="controller" />

</beans>