2017-04-16 94 views
1

我找到了它的stackoverflow,並在Android中找到一篇文章,但我不認爲這適合我。有效的XML文檔必須有一個根標籤

Selector for button error "Valid XML document must have a root tag"

我的快照低於:

enter image description here

而且我的代碼在spring_datasource.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" 
     xmlns:context="http://www.springframework.org/schema/context" 
     xmlns:aop="http://www.springframework.org/schema/aop" 
     xmlns:tx="http://www.springframework.org/schema/tx" 
     xmlns:mvc="http://www.springframework.org/schema/mvc" 
     xmlns:task="http://www.springframework.org/schema/task" xmlns:cache="http://www.springframework.org/schema/cache" 
     xsi:schemaLocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.1.xsd 
        http://www.springframework.org/schema/tx 
        http://www.springframework.org/schema/tx/spring-tx-3.1.xsd 
        http://www.springframework.org/schema/aop 
        http://www.springframework.org/schema/aop/spring-aop-3.1.xsd 
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd 
        http://www.springframework.org/schema/task 
        http://www.springframework.org/schema/task/spring-task-3.1.xsd 
        http://www.springframework.org/schema/cache 
        http://www.springframework.org/schema/cache/spring-cache.xsd"> 


    <!--資源載入器 --> 
    <bean 
      class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
     <property name="locations"> 
      <list> 
       <value>classpath:config.properties</value> 
      </list> 
     </property> 
    </bean> 
    <!--數據連接池 --> 
    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" 
      init-method="init" destroy-method="close"> 
     <property name="url" value="${connection.url}" /> 
     <property name="username" value="${connection.username}" /> 
     <property name="password" value="${connection.password}" /> 
     <property name="initialSize" value="${connection.initialSize}" /> 
     <property name="minIdle" value="${connection.minIdle}" /> 
     <property name="maxActive" value="${connection.maxActive}" /> 

     <!-- 配置獲取連接等待超時的時間 --> 
     <property name="maxWait" value="60000" /> 
     <!-- 配置間隔多久才進行一次檢測,檢測需要關閉的空閒連接,單位是毫秒 --> 
     <property name="timeBetweenEvictionRunsMillis" value="60000" /> 
     <!-- 配置一個連接在池中最小生存的時間,單位是毫秒 --> 
     <property name="minEvictableIdleTimeMillis" value="300000" /> 
     <property name="testWhileIdle" value="true" /> 
     <property name="testOnBorrow" value="false" /> 
     <property name="testOnReturn" value="false" /> 
    </bean> 

    <!-- (事務管理)transaction manager, use JtaTransactionManager for global tx --> 
    <bean id="transactionManager" 
      class="org.springframework.orm.hibernate4.HibernateTransactionManager"> 
     <property name="sessionFactory" ref="sessionFactory" /> 
    </bean> 

    <!-- 基於註解的事物管理 --> 
    <tx:annotation-driven transaction-manager="transactionManager" /> 
    <!-- 當在web.xml 中DispatcherServlet使用<url-pattern>/</url-pattern> 映射時, 
    能映射靜態資源(當Spring Web MVC框架沒有處理請求對應的控制器時(如一些靜態資源), 
    轉交給默認的Servlet來響應靜態文件,否則報404找不到資源錯誤,)。--> 
    <mvc:default-servlet-handler /> 

    <!-- spring和hibernate整合 --> 
    <bean id="sessionFactory" 
      class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> 
     <property name="dataSource" ref="dataSource" /> 
     <property name="hibernateProperties"> 
      <props> 
       <prop key="hibernate.dialect"> 
        ${hibernate.dialect} 
       </prop> 
       <prop key="hibernate.show_sql"> 
        ${hibernate.show_sql} 
       </prop> 
       <prop key="hibernate.format_sql"> 
        ${hibernate.format_sql} 
       </prop> 
       <prop key="hibernate.hbm2ddl.auto"> 
        ${hibernate.hbm2ddl.auto} 
       </prop> 
       <prop key="hibernate.jdbc.batch_size"> 
        ${hibernate.jdbc.batch_size} 
       </prop> 
       <prop key="hibernate.autoReconnect">true</prop> 
      </props> 
     </property> 
     <property name="packagesToScan"> 
      <list> 
       <value>com.ldl.vision86.common.basis.entity</value> 
       <value>com.ldl.vision86.business.entity</value> 
      </list> 
     </property> 
    </bean> 
    <!-- 定時器配置 
     task:executor/@pool-size:可以指定執行線程池的初始大小、最大大小 
     task:executor/@queue-capacity:等待執行的任務隊列的容量 
     task:executor/@rejection-policy:當等待隊已滿時的策略,分爲丟棄、由任務執行器直接運行等方式 
     --> 
    <task:scheduler id="scheduler" pool-size="10" /> 
    <task:executor id="executor" keep-alive="3600" pool-size="100-200" 
        queue-capacity="500" rejection-policy="CALLER_RUNS" /> 
    <task:annotation-driven executor="executor" scheduler="scheduler" /> 
</beans> 

我不知道在哪裏的問題。

回答

0

您的XML是沒有問題的。

嘗試單擊Create Spring構面。

enter image description here

相關問題