使用MyEclipse10.7整合Struts2.1+Spring3.0+Hibernate3.3。 在DB Borwser透视图中,Hibernate Reverse Engineering向导进行表的映射和DAO自动生成时
控制台显示如下错误,请问怎么解决 2015-08-07 17:42:58,091 ERROR Worker-13 org.hibernate.util.XMLHelper – Error parsing XML: D:\Workspaces\PokeManagerSystem\WebRoot\WEB-INF\applicationContext.xml(3) Document is invalid: no grammar found. applicationContext.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: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"> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"> </property> <property name="url" value="jdbc:mysql://localhost:3306/Pokemon"> </property> <property name="username" value="root"></property> <property name="password" value="laomin"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> </props> </property> <property name="mappingResources"> <list> <value>com/poke/po/Manager.hbm.xml</value> <value>com/poke/po/Player.hbm.xml</value> <value>com/poke/po/Asd.hbm.xml</value></list> </property></bean> <bean id="ManagerDAO" class="com.poke.po.ManagerDAO"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <bean id="PlayerDAO" class="com.poke.po.PlayerDAO"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <bean id="AsdDAO" class="com.poke.po.AsdDAO"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean></beans> |
|
#140分 |
修改为以下内容试一下
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> <beans> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"> </property> <property name="url" value="jdbc:mysql://localhost:3306/Pokemon"> </property> <property name="username" value="root"></property> <property name="password" value="laomin"></property> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref bean="dataSource" /> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </prop> </props> </property> <property name="mappingResources"> <list> <value>com/poke/po/Manager.hbm.xml</value> <value>com/poke/po/Player.hbm.xml</value> <value>com/poke/po/Asd.hbm.xml</value></list> </property></bean> <bean id="ManagerDAO" class="com.poke.po.ManagerDAO"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <bean id="PlayerDAO" class="com.poke.po.PlayerDAO"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <bean id="AsdDAO" class="com.poke.po.AsdDAO"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean></beans> |
#2 |
其实就是 在xml文件的第一行 下面 加一行
<!DOCTYPE beans PUBLIC “-//SPRING//DTD BEAN//EN” “http://www.springframework.org/dtd/spring-beans.dtd”> 就可以了 |
#3 |
回复1楼:
嗯嗯,可以了,太感谢了,能告诉下我原因是什么吗?是Spring和Hibernate版本不兼容?导致不能用schema那个开头?能说说吗?
|