2011-03-16 79 views
2

有人可以帮助我解决Xml在编写Hibernate-Spring程序时Doctype与Schema的奥秘吗?我第一次写它可以帮助我的任何版本。我在网上读到:Xml-Mystery编写Hibernate与Spring

  1. 架构是XML需要为Spring 2.x和3.1冬眠
  2. 文档类型所需的早期版本

任何一个可以告诉我是什么意义我们写在我们的模式和什么时候使用什么的n + 1数量的等等等等。

在此先感谢。

+0

这个异常让我疯狂 线程“main”中的异常org.springframework.beans.factory.BeanDefinitionStoreException:来自类路径资源[spring-hibernate.xml]的XML文档中的第6行无效;嵌套异常是org.xml.sax.SAXParseException:文档根元素“beans”,必须匹配DOCTYPE根“null”。 org.xml.sax.SAXParseException:文档根元素“beans”,必须匹配DOCTYPE根“null”。 – 2011-03-16 05:31:17

+0

如果答案满足您的要求,则应在其附近放置一个绿色勾号标记。 – 2011-03-16 11:13:04

回答

2

它的时间来升级您的版本的春季和休眠。

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc" 
    xmlns:jee="http://www.springframework.org/schema/jee" xmlns:context="http://www.springframework.org/schema/context" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
         http://www.springframework.org/schema/beans/spring-beans.xsd 
         http://www.springframework.org/schema/aop 
         http://www.springframework.org/schema/aop/spring-aop-2.5.xsd 
         http://www.springframework.org/schema/tx 
         http://www.springframework.org/schema/tx/spring-tx-2.5.xsd 
         http://www.springframework.org/schema/context 
         http://www.springframework.org/schema/context/spring-context-3.0.xsd 
         http://www.springframework.org/schema/mvc 


     http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"></beans> 

所以用这个豆命名空间定义,你将能够使用AOP,TX,JEE,背景和您的Spring应用程序上下文MVC标签。所有的bean都要在元素中声明(这从标签名称本身是很明显的)。大多数支持Spring集成的IDE都可以帮助您定义bean文件和名称空间。我会推荐STS。