Spring3启动失败

玫瑰花的葬礼 发布于 2012/12/13 17:44
阅读 364
收藏 0

Spring配置文件如下:(Spring使用3.1.3版,Hibernate使用4.1.8版)

<?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: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/context 
            http://www.springframework.org/schema/context/spring-context-3.0.xsd">


<!-- 开启注解处理器 -->
    <context:annotation-config/>
    
    <!-- 注册Hibernate -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="annotatedClasses">
    <list>
    <value>m.bean.User</value>
    <value>m.bean.Account</value>
    </list>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
    <prop key="hibernate.connection.url">jdbc:mysql://localhost:3306/management?useUnicode=true&amp;characterEncoding=gbk</prop>
    <prop key="hibernate.connection.username">userName</prop>
    <prop key="hibernate.connection.password">userPassword</prop>
    <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
    <prop key="hibernate.current_session_context_class">thread</prop>
    <prop key="hibernate.jdbc.batch_size">50</prop>
    <prop key="hibernate.show_sql">false</prop>
    <prop key="hibernate.format_sql">false</prop>
    </props>
    </property>
    </bean>
    <!-- 数据访问实现类 -->
    <bean id="basicDaoImpl" class="m.dao.impl.BasicDaoImpl"/>
    <bean id="userDaoImpl" class="m.dao.impl.UserDaoImpl"/>
    <bean id="accountDaoImpl" class="m.dao.impl.AccountDaoImpl"/>
    <bean id="safeDaoImpl" class="m.dao.impl.SafeDaoImpl"/>
    <!-- 数据装配实现类 -->
    <bean id="userServiceImpl" class="m.service.impl.UserServiceImpl"/>
    <bean id="accountServiceImpl" class="m.service.impl.AccountServiceImpl"/>
    <!-- 数据处理实现类 -->
    <bean id="userProcessImpl" class="m.process.impl.UserProcessImpl"/>
    <bean id="accountProcessImpl" class="m.process.impl.AccountProcessImpl"/>
    <!-- 弹出窗体 -->
    <bean id="show" class="m.view.Show"/>
</beans>

错误信息如下:

org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context]

Offending resource: class path resource [applicationContext.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.error(BeanDefinitionParserDelegate.java:316)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1420)
at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1413)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:184)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:140)
at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:111)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:131)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:530)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:444)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at m.view.Login.main(Login.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.exe4j.runtime.LauncherEngine.launch(Unknown Source)
at com.exe4j.runtime.WinLauncher.main(Unknown Source)

以下是问题补充:

@玫瑰花的葬礼:在MyEclipse8.5中启动这个小项目时不会出现任何错误。 但把应用打包成exe格式启动时就会出现这个错误。 (2012/12/13 18:01)
加载中
0
whaon
whaon

xmlns:p="http://www.springframework.org/schema/p"

介个是什么

0
玫瑰花的葬礼
玫瑰花的葬礼

引用来自“whaon”的答案

xmlns:p="http://www.springframework.org/schema/p"

介个是什么

去掉

xmlns:p="http://www.springframework.org/schema/p"

也没有用。

返回顶部
顶部