执行程序以读取属性文件时找不到元素“ beans”的声明

时间:2018-12-03 07:53:06

标签: java spring

我只是尝试使用带有xml的spring通过我的代码读取一个属性文件。这是我的spring.xml文件的代码。

  DataModel dm = new ListDataModel<Ratings>(ratings, "UserId", "ISBN", "Rate");

  UserSimilarity sim = Users.UncenteredCosineSimilarity(dm);

  UserNeighborhood neighborhood = new NearestNUserNeighborhood(10,.1, sim, dm); 
//when reaches here App never stops and nothing return

执行时出现此错误。

由以下原因引起:org.xml.sax.SAXParseException; lineNumber:4; columnNumber:152; cvc-elt.1:找不到元素'beans'的声明。

任何建议。

1 个答案:

答案 0 :(得分:0)

我认为您的xsi:schemaLocation不正确,请尝试以下方法:

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">

P.S。每行中的xsi:schemaLocation有两个值,以空格分隔。第一个值是要使用的名称空间。第二个值是用于该名称空间的XML模式的位置。 schemaLocation中没有位置,解析器认为... util是... bean的位置。并在架构中找不到“ beans”:“找不到元素'beans'的声明”