找不到元素[bean]的BeanDefinitionParser

时间:2015-06-07 14:35:44

标签: java maven spring-mvc apache-tiles

我正在跟随this教程使用Apache Tiles 3我的项目servlet-context.xml是:

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc 
http://www.springframework.org/schema/mvc/spring-mvc.xsd        
http://www.springframework.org/schema/beans  
http://www.springframework.org/schema/beans/spring-beans.xsd        
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context.xsd">

<!-- DispatcherServlet Context: defines this servlet's request-processing 
    infrastructure -->

<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven />

<!-- Handles HTTP GET requests for /resources/** by efficiently serving 
    up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />

<!-- Resolves views selected for rendering by @Controllers to .jsp resources 
    in the /WEB-INF/views directory -->
<beans:bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <beans:property name="prefix" value="/WEB-INF/views/" />
    <beans:property name="suffix" value=".jsp" />
</beans:bean>

<context:component-scan base-package="ali.arshad.soomro" />

<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"> 
    <property name="definitions"> 
    <list> 
    <value>/WEB-INF/defs/general.xml</value>        
    </list> 
    </property> 
</bean> 
    <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> 
    <property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView" 
    /> </bean>
</beans:beans>

这里我面临错误

  

此行找到多个注释:        - 配置问题:找不到元素[bean] Offending资源的BeanDefinitionParser:file [G:/ Spring / java-blog / src / main / webapp /        WEB-INF /弹簧/ appServlet / servlet的context.xml中]        - 找不到元素[bean]的BeanDefinitionParser        - cvc-complex-type.2.4.c:匹配的通配符是strict,但是没有为元素'bean'找到声明。

在第class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"行和错误

  

cvc-complex-type.2.4.c:匹配的通配符是strict,但是没有找到元素'bean'的声明。

在第class="org.springframework.web.servlet.view.UrlBasedViewResolver"行。

pom.xml依赖项是

<dependency> 
    <groupId>org.apache.tiles</groupId> 
    <artifactId>tiles-api</artifactId> 
        <version>3.0.3</version> 
    </dependency> 
    <dependency> 
    <groupId>org.apache.tiles</groupId> 
        <artifactId>tiles-core</artifactId> 
        <version>3.0.3</version> 
    </dependency> 
    <dependency> 
    <groupId>org.apache.tiles</groupId> 
    <artifactId>tiles-jsp</artifactId> 
        <version>3.0.3</version> 
    </dependency> 
    <dependency> 
    <groupId>org.apache.tiles</groupId> 
        <artifactId>tiles-servlet</artifactId> 
        <version>3.0.3</version> 
    </dependency> 
        <dependency> 
        <groupId>org.apache.tiles</groupId> 
        <artifactId>tiles-template</artifactId> 
        <version>3.0.3</version> 
    </dependency>

更新 在下面的答案中提出建议后,我在servlet-contex.xml中作为

进行了更改
<beans:bean class="org.springframework.web.servlet.view.tiles3.TilesViewResolver">
<beans:property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView"></beans:property>
<beans:property name="order" value="0"></beans:property>
</beans:bean>
<beans:bean class="org.springframework.web.servlet.view.tiles3.TilesConfigurer" id="tilesConfigurer">
 <beans:property name="definitions" value="/WEB-INF/spring/tiles.xml"> </beans:property>
</beans:bean>

现在我收到此错误

  

属性:class   bean类的完全限定名称,除非它仅用作child的父定义    bean定义。

     

数据类型:字符串

class="org.springframework.web.servlet.view.tiles3.TilesViewResolver"

在第class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"行 任何人都可以建议我解决这些错误吗?

1 个答案:

答案 0 :(得分:1)

问题在于命名空间。您应该拥有以bean开头的所有标签