Cannot locate BeanDefinitionParser for element [bean]

☆樱花仙子☆ 提交于 2019-12-11 21:09:48

问题


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>

here I'm facing error

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

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

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

at line class="org.springframework.web.servlet.view.UrlBasedViewResolver".

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>

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>

Now I get this error

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

Data Type : string

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?


回答1:


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



来源:https://stackoverflow.com/questions/30694735/cannot-locate-beandefinitionparser-for-element-bean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!