找不到元素[bean]的BeanDefinitionParser [英] Cannot locate BeanDefinitionParser for element [bean]

查看:115
本文介绍了找不到元素[bean]的BeanDefinitionParser的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与教程一起使用,以与

I'm following along with this tutorial to work with Apache Tiles 3 my projects servlet-context.xml is :

<?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]的BeanDefinitionParser有害资源:文件[G:/Spring/java-blog/src/main/webapp/ WEB-INF/spring/appServlet/servlet-context.xml] -找不到元素[bean]的BeanDefinitionParser -cvc-complex-type.2.4.c:匹配的通配符很严格,但是找不到元素'bean'的声明.

Multiple annotations found at this line: - Configuration problem: Cannot locate BeanDefinitionParser for element [bean] Offending resource: file [G:/Spring/java-blog/src/main/webapp/ WEB-INF/spring/appServlet/servlet-context.xml] - Cannot locate BeanDefinitionParser for element [bean] - cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'bean'.

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

at line class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"
and error

cvc-complex-type.2.4.c:匹配的通配符很严格,但是找不到元素'bean'的声明.

cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'bean'.

class="org.springframework.web.servlet.view.UrlBasedViewResolver"行.

pom.xml依赖项是

pom.xml dependencies are

<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更改为

UPDATE after suggestion in Answer below I have made change in servlet-contex.xml as

<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>

现在我收到此错误

属性:类 Bean类的全限定名,除非它仅用作子级的父级定义 Bean定义.

Attribute : class The fully qualified name of the bean's class, except if it serves only as a parent definition for child bean definitions.

数据类型:字符串

在行class="org.springframework.web.servlet.view.tiles3.TilesViewResolver"上的

并在class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"
行 请问有人可以建议我解决这些错误吗?

at line class="org.springframework.web.servlet.view.tiles3.TilesViewResolver" and at line class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"
Please can any one suggest me a solution to these errors?

推荐答案

问题与命名空间有关.您应该拥有所有以bean开头的标签

Issue is with namespace. You should have all tags starting with beans

这篇关于找不到元素[bean]的BeanDefinitionParser的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆