gpt4 book ai didi

java - 元素类型 "property"的内容必须匹配

转载 作者:数据小太阳 更新时间:2023-10-29 02:13:39 26 4
gpt4 key购买 nike

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<bean id="triangle" class="bean.Trinangle">
<property name="points">
<list>
<ref bean="point1"/>
<ref bean="point2"/>
<ref bean="point3"/>
</list>
</property>
</bean>

<bean id= "point1" class="bean.Point">
<property name="x" value="10"/>
<property name="y" value="20"/>
</bean>

<bean id= "point2" class="bean.Point">
<property name="x" value="10"/>
<property name="y" value="20"/>
</bean>

<bean id= "point3" class="bean.Point">
<property name="x" value="10"/>
<property name="y" value="20"/>
</bean>
</beans>

问题:这是我的 XML 文件。在第 6 行我收到错误“他的元素类型“属性”的内容必须匹配“(描述?,meta *,(bean | ref | idref | value | null | list | set | map | Prop )?)“。”。

最佳答案

我认为您实际上并没有创建一个列表(如果那是 setPoints 所期望的)。尝试这样的事情(取自 How to define a List bean in Spring? ):

<?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:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">


<beans>

<bean id= "point1" class="bean.Point">
<property name="x" value="10"/>
<property name="y" value="20"/>
</bean>
<bean id= "point2" class="bean.Point">
<property name="x" value="10"/>
<property name="y" value="20"/>
</bean>
<bean id= "point3" class="bean.Point">
<property name="x" value="10"/>
<property name="y" value="20"/>
</bean>

<util:list id="pointList" value-type="bean.Point">
<value>point1</value>
<value>point2</value>
<value>point3</value>
</util:list>


<bean id="triangle" class="bean.Trinangle">
<property name="points" value="pointList" />
</bean>

<bean id= "point1" class="bean.Point">
<property name="x" value="10"/>
<property name="y" value="20"/>
</bean>
<bean id= "point2" class="bean.Point">
<property name="x" value="10"/>
<property name="y" value="20"/>
</bean>
<bean id= "point3" class="bean.Point">
<property name="x" value="10"/>
<property name="y" value="20"/>
</bean>
</beans>

关于java - 元素类型 "property"的内容必须匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36125149/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com