spring+struts2+mybits 出错

  Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 1 in XML document from class path resource [] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; 前言中不允许有内容。
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:399)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:336)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:304)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:181)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:217)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:188)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:129)
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:452)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4727)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5189)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:596)
    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1805)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; 前言中不允许有内容。
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:76)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadDocument(XmlBeanDefinitionReader.java:429)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
    ... 26 more
    java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date [Wed Feb 15 22:47:01 CST 2017]; root of context hierarchy
    at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:344)
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:331)
    at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:869)
    at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:836)
    at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:579)
    at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:115)
    at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:4774)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5411)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:226)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:596)
    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1805)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

二月 15, 2017 10:47:02 下午 org.springframework.web.context.support.XmlWebApplicationContext doClose
警告: Exception thrown from LifecycleProcessor on context close

已解决。classpath:Xxx.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:aop="http://www.springframework.org/schema/aop"
            xmlns:tx="http://www.springframework.org/schema/tx"
            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/aop
                                             http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
                                             http://www.springframework.org/schema/tx
                                             http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> 
                <!-- 加载jdbc配置文件,ongl方式 -->
                <context:property-placeholder location="jdbc.properties"/>
                <!-- c3p0 -->
                <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
                            <property name="driverClass" value="${driverClass}"/>
                            <property name="jdbcUrl" value="${jdbcUrl}"/>
                            <property name="user" value="${user}"/>
                            <property name="password" value="${password}"/>
                            <!-- 其他参数的配置,参考官方文档 -->
                </bean>
                <!-- 配置session -->
                <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
                        <property name="dataSource" ref="dataSource"/>
                </bean>
                <!-- 配置 tx -->
                <bean id="tx" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
                        <property name="dataSource" ref="dataSource"/>
                </bean>
                <!-- 配置tx管理的方法,管理的制度 -->
                <tx:advice id="txAdvice" transaction-manager="tx">
                            <tx:attributes>
                                <tx:method name="find*" read-only="true"/>
                                <tx:method name="insert*"/>
                                <tx:method name="update*"/>
                                <tx:method name="delete*"/>
                            </tx:attributes>
                </tx:advice>
                <!-- 配置aop -->
                <aop:config>
                    <!-- pointcut(切点),需要进行 aop 编程的方法 -->
                        <aop:pointcut expression="execution(* com.bdqn.front.dao.*.*(..))" id="frontPointcut"/>
                        <!-- 执行者 -->
                        <aop:advisor advice-ref="txAdvice" pointcut-ref="frontPointcut"/>
                </aop:config>
   </beans>
 <?xml version="1.0" encoding="UTF-8"?>  
<beans xmlns="http://www.springframework.org/schema/beans"    
    default-autowire="byName"    
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
    xsi:schemaLocation="
                http://www.springframework.org/schema/beans
                http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> 

                <!-- 设置 mapper 的interface -->
                <bean id="SysdataDao" class="org.mybatis.spring.mapper.MapperFactoryBean">
                        <property name="mapperInterface" value="com.bdqn.front.dao.SysdataDao"/>
                        <property name="sqlSessionFactory" ref="sqlSessionFactory"></property>
                </bean>
                 <bean id="AnnouncementDao" class="org.mybatis.spring.mapper.MapperFactoryBean">
                        <property name="mapperInterface" value="com.bdqn.front.dao.AnnouncementDao"/>
                        <property name="sqlSessionFactory" ref="sqlSessionFactory"></property>
                </bean>
                <bean id="ClassmanageDao" class="org.mybatis.spring.mapper.MapperFactoryBean">
                        <property name="mapperInterface" value="com.bdqn.front.dao.ClassmanageDao"/>
                        <property name="sqlSessionFactory" ref="sqlSessionFactory"></property>
                </bean>
                 <bean id="CommentDao" class="org.mybatis.spring.mapper.MapperFactoryBean">
                        <property name="mapperInterface" value="com.bdqn.front.dao.CommentDao"/>
                        <property name="sqlSessionFactory" ref="sqlSessionFactory"></property>
                </bean>
                <bean id="MemberDao" class="org.mybatis.spring.mapper.MapperFactoryBean">
                        <property name="mapperInterface" value="com.bdqn.front.dao.MemberDao"/>
                        <property name="sqlSessionFactory" ref="sqlSessionFactory"></property>
                </bean>
                 <bean id="NewsDao" class="org.mybatis.spring.mapper.MapperFactoryBean">
                        <property name="mapperInterface" value="com.bdqn.front.dao.NewsDao"/>
                        <property name="sqlSessionFactory" ref="sqlSessionFactory"></property>
                </bean>
                 <bean id="StudentDao" class="org.mybatis.spring.mapper.MapperFactoryBean">
                        <property name="mapperInterface" value="com.bdqn.front.dao.StudentDao"/>
                        <property name="sqlSessionFactory" ref="sqlSessionFactory"></property>
                </bean>
   </beans>
 <!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
  <display-name>Archetype Created Web Application</display-name>
  <!-- 加载spring的配置文件 -->
  <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath: spring-mybatis.xml,classpath:   spring-mybatis-dao.xml</param-value>
  </context-param>

  <!-- 启动struts2 -->
  <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class>
  </filter>
  <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
  </filter-mapping>
  <!-- 配置spring的监听器,将容器与spring整合 -->
  <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
</web-app>


图片说明