2016-08-29 179 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 相同,所以你得到的例外。