2016-08-29 163 views
0

請問一些請讓我知道我在這裏失蹤的東西。我得到以下例外春季豆標記錯誤

Line 76 in XML document from file [C:\S2\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\proj_name\WEB-INF\classes\spring\test-context.xml] is invalid; nested exception is 
org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content 
was found starting with element 'bean'. One of '{"http://www.springframework.org/schema/beans":description, 
    "http://www.springframework.org/schema/beans":meta,    
"http://www.springframework.org/schema/beans":constructor-arg,  "http://www.springframework.org/schema/beans":property, "http://www.springframework.org/schema/beans":qualifier, "http://www.springframework.org/schema/beans":lookup-method, "http://www.springframework.org/schema/beans":replaced-method,  WC[##other:"http://www.springframework.org/schema/beans"]}' is expected. 

而且我有我的test-context.xml如下。

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:batch="http://www.springframework.org/schema/batch" 
    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-3.0.xsd 
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd"> 

<bean id="restAuthenticationEntryPoint" class="com.test.security.RestAuthenticationEntryPoint"> 

有誰請讓我知道我爲什麼在這裏失蹤。我有春春3.0.5罐子

回答

1

你缺少周邊<beans></beans>標籤:

<beans> 
    <bean id="restAuthenticationEntryPoint" class="com.test.security.RestAuthenticationEntryPoint"> 
<beans> 

這是錯誤消息要告訴你......

無效的含量被發現從元素'bean'開始。

「的bean標籤在這裏不允許」

一個[..]豆類,[..]預計

唯一有效的標籤的下面是 「豆」等

+0

非常感謝您節省了我的時間。 – ashishl

0

<beans:beans/>添加到您的配置xml。

<beans:beans xmlns="http://www.springframework.org/schema/beans" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns:batch="http://www.springframework.org/schema/batch" 
      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-3.0.xsd 
     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 
     http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd"> 

    <beans:beans id="restAuthenticationEntryPoint" class="com.test.security.RestAuthenticationEntryPoint"/> 

</beans:beans> 

在你的xml中,你打開了<bean>標籤但沒有關閉。 <beans xmlns....> 其中是</beans>restAuthenticationEntryPoint 相同,所以你得到的例外。