发现内容以元素“ property”开头的内容无效

用户名

我收到此错误:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 45 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 45; columnNumber: 42; cvc-complex-type.2.4.a: Invalid content was found starting with element 'property'. One of '{"http://www.springframework.org/schema/beans":import, "http://www.springframework.org/schema/beans":alias, "http://www.springframework.org/schema/beans":bean, WC[##other:"http://www.springframework.org/schema/beans"], "http://www.springframework.org/schema/beans":beans}' is expected.

这是applicationContext.xml

<?xml version='1.0' encoding='UTF-8' ?>
<!-- was: <?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"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
                         http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
                         http://www.springframework.org/schema/aop
                        http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
                        http://www.springframework.org/schema/tx
                        http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
                        http://www.springframework.org/schema/context
                        http://www.springframework.org/schema/context/spring-context.xsd
                        http://www.springframework.org/schema/jdbc 
                       http://www.springframework.org/schema/jdbc/spring-jdbc.xsd">

<tx:annotation-driven/>

<context:component-scan base-package="com.sajjad" />


<bean id="dataSource"
      class="org.springframework.jdbc.datasource.DriverManagerDataSource"
      p:driverClassName="${jdbc.driverClassName}"
      p:url="${jdbc.url}"
      p:username="${jdbc.username}"
      p:password="${jdbc.password}" />

<bean id="sessionFactory"
      class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"   
      p:dataSource-ref="dataSource"
      p:packagesToScan="com.sajjad"
      p:hibernateProperties-ref="hibernateProperties" />


<property name="hibernateProperties">
    <props>
        <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
        <prop key="hibernate.show_sql">true</prop>
    </props>
</property>

<!--    <util:properties id="hibernateProperties" >
    <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
    <prop key="hibernate.show_sql">true</prop>
</util:properties>-->

</beans>

web.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" `xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" `xsi:schemaLocation="http://java.sun.com/xml/ns/javaee`
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">`
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <context-param>
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>*.xhtm</url-pattern>
    </servlet-mapping>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>

我也为<util>标签得到了这个错误

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 52 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 52; columnNumber: 52; The prefix "util" for element "util:properties" is not bound.
安妮达(Aninda Bhattacharyya)

您在</beans>这里缺少结束标记applicationContext.xml

对于util,您还需要声明名称空间...

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

您可以做类似...

<util:map id="hibernateConfig" >
    <entry key="hibernate.hbm2ddl.auto" value="update" />
    <entry key="hibernate.show_sql" value="true" />
    <!-- Other properties -->
</util:map>

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"
..
..
p:hibernateProperties-ref ="hibernateConfig"/>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

发现内容以元素“ property”开头的内容无效

来自分类Dev

Maven:发现无效的内容以元素“ plugin”开头

来自分类Dev

发现无效的内容,以元素“ hc:html”开头

来自分类Dev

发现以元素“Generator”开头的无效内容

来自分类Dev

发现XML无效的内容以元素开头。预期为“ {}”之一

来自分类Dev

如何“解决发现以元素开头的无效内容” Schematron错误?

来自分类Dev

发现无效的内容以元素“ global-method-security”开头

来自分类Dev

发现无效的内容以元素“ global-method-security”开头

来自分类Dev

发现无效的内容以元素“ init-param”开头

来自分类Dev

从元素开始发现无效的内容

来自分类Dev

使用Maven进行Mule编译失败:以元素'db:generic-config'开头发现无效内容

来自分类Dev

HandlerInterceptorAdaptarer Spring-从元素'bean'开始发现无效内容

来自分类Dev

从元素文件:inbound-endpoint开始发现无效内容

来自分类Dev

cvc-complex-type.2.4。在faces-config.xml中发现了以元素工厂开头的无效内容

来自分类Dev

内容开头的目标元素

来自分类Dev

出现错误cvc-complex-type.2.4.d:通过Java代码编译jrxml时,发现以元素“ paragraph”开头的内容无效

来自分类Dev

cvc-complex-type.2.4.a:发现无效的内容(从元素'MarkupListURI'开始)。预期为“ {MarkupDeleteURI}”之一

来自分类Dev

cvc-complex-type.2.4.a:发现无效的内容(从元素'ProcessDesc'开始)。预期为ProcessName之一

来自分类Dev

使用Maven进行Mule编译失败:从元素'db:generic-config'开始发现无效内容

来自分类Dev

cvc-complex-type.2.4.a:发现无效的内容(从元素“ bean”开始)

来自分类Dev

Spring Security XML错误-cvc-complex-type.2.4.a:发现无效的内容(从元素“ csrf”开始)

来自分类Dev

cvc-complex-type.2.4.a:发现无效的内容(从元素“ param”开始)。预期为“ {param}”之一

来自分类Dev

lineNumber:12; columnNumber:139; cvc-complex-type.2.4.a:发现无效的内容(从元素'beans:bean'开始)

来自分类Dev

XSD错误中的XML发现无效内容

来自分类Dev

Android SDK安装。错误:发现从元素'd:skin'开始的无效内容。目前预计没有子元素

来自分类Dev

Twilio错误:“ 12200架构验证警告说明”从元素'Message'开始发现无效的内容。'{Play“之一

来自分类Dev

'解组错误:cvc-complex-type.2.4.a:发现无效的内容,从元素'XXXXX'开始。预期为“ {XXXXX}”之一

来自分类Dev

Twilio错误:“ 12200架构验证警告说明”从元素'Message'开始发现无效的内容。'{Play“之一

来自分类Dev

MongoDB,批量发现返回的内容

Related 相关文章

  1. 1

    发现内容以元素“ property”开头的内容无效

  2. 2

    Maven:发现无效的内容以元素“ plugin”开头

  3. 3

    发现无效的内容,以元素“ hc:html”开头

  4. 4

    发现以元素“Generator”开头的无效内容

  5. 5

    发现XML无效的内容以元素开头。预期为“ {}”之一

  6. 6

    如何“解决发现以元素开头的无效内容” Schematron错误?

  7. 7

    发现无效的内容以元素“ global-method-security”开头

  8. 8

    发现无效的内容以元素“ global-method-security”开头

  9. 9

    发现无效的内容以元素“ init-param”开头

  10. 10

    从元素开始发现无效的内容

  11. 11

    使用Maven进行Mule编译失败:以元素'db:generic-config'开头发现无效内容

  12. 12

    HandlerInterceptorAdaptarer Spring-从元素'bean'开始发现无效内容

  13. 13

    从元素文件:inbound-endpoint开始发现无效内容

  14. 14

    cvc-complex-type.2.4。在faces-config.xml中发现了以元素工厂开头的无效内容

  15. 15

    内容开头的目标元素

  16. 16

    出现错误cvc-complex-type.2.4.d:通过Java代码编译jrxml时,发现以元素“ paragraph”开头的内容无效

  17. 17

    cvc-complex-type.2.4.a:发现无效的内容(从元素'MarkupListURI'开始)。预期为“ {MarkupDeleteURI}”之一

  18. 18

    cvc-complex-type.2.4.a:发现无效的内容(从元素'ProcessDesc'开始)。预期为ProcessName之一

  19. 19

    使用Maven进行Mule编译失败:从元素'db:generic-config'开始发现无效内容

  20. 20

    cvc-complex-type.2.4.a:发现无效的内容(从元素“ bean”开始)

  21. 21

    Spring Security XML错误-cvc-complex-type.2.4.a:发现无效的内容(从元素“ csrf”开始)

  22. 22

    cvc-complex-type.2.4.a:发现无效的内容(从元素“ param”开始)。预期为“ {param}”之一

  23. 23

    lineNumber:12; columnNumber:139; cvc-complex-type.2.4.a:发现无效的内容(从元素'beans:bean'开始)

  24. 24

    XSD错误中的XML发现无效内容

  25. 25

    Android SDK安装。错误:发现从元素'd:skin'开始的无效内容。目前预计没有子元素

  26. 26

    Twilio错误:“ 12200架构验证警告说明”从元素'Message'开始发现无效的内容。'{Play“之一

  27. 27

    '解组错误:cvc-complex-type.2.4.a:发现无效的内容,从元素'XXXXX'开始。预期为“ {XXXXX}”之一

  28. 28

    Twilio错误:“ 12200架构验证警告说明”从元素'Message'开始发现无效的内容。'{Play“之一

  29. 29

    MongoDB,批量发现返回的内容

热门标签

归档