2017-05-05 69 views
-1

我試圖在Tomcat 8部署我的應用程序,但我得到這個錯誤org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSecurityFilterChain' is definedorg.springframework.beans.factory.NoSuchBeanDefinitionException:無豆命名爲「springSecurityFilterChain」被定義

,這是我的web.xml文件

<?xml version="1.0" encoding="UTF-8"?> 

http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd」 版本= 「3.1」>

<servlet> 
    <servlet-name>dispatcher</servlet-name> 
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
    <load-on-startup>1</load-on-startup> 
</servlet> 
<servlet-mapping> 
    <servlet-name>dispatcher</servlet-name> 
    <url-pattern>*.htm</url-pattern> 
</servlet-mapping> 

<listener> 
    <listener-class> 
     org.springframework.web.context.ContextLoaderListener 
    </listener-class> 
</listener> 
<context-param> 
    <param-name>contxtConfigLocation</param-name> 
    <param-value>/WEB-INF/applicationContext.xml</param-value> 
</context-param> 

<!--Security Filter--> 
<filter> 
    <filter-name>springSecurityFilterChain</filter-name> 
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> 
</filter> 
<filter-mapping> 
    <filter-name>springSecurityFilterChain</filter-name> 
    <url-pattern>/*</url-pattern> 
</filter-mapping> 

<welcome-file-list> 
    <welcome-file>login.htm</welcome-file> 
</welcome-file-list> 
<session-config> 
    <session-timeout> 
     30 
    </session-timeout> 
</session-config> 

,這是Spring配置文件(調度員servlet.xml中)

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

    <context:annotation-config/> 
    <context:component-scan base-package="com.iti.annotation.controller,com.iti.dao"/> 
    <mvc:annotation-driven/> 
    <bean id="viewResolver" 
      class="org.springframework.web.servlet.view.InternalResourceViewResolver" 
      p:prefix="/WEB-INF/jsp/" 
      p:suffix=".jsp" > 
    </bean> 

    <!--Security--> 
    <bean id="springSecurityFilterChain" class="javax.servlet.Filter"/> 
    <!--Security Authentication-Manager--> 
    <security:authentication-manager> 
     <security:authentication-provider> 
      <security:user-service> 
       <security:user name="samir" password="1234" authorities="ROLE_USER" /> 
       <security:user name="admin" password="ZXCASDDFAERDFD" authorities="ROLE_USER,ROLE_ADMIN" /> 
      </security:user-service> 
     </security:authentication-provider> 
    </security:authentication-manager> 

    <!--securing web requests--> 

    <security:http auto-config="true" use-expressions="true" > 
     <security:form-login login-processing-url="/secure_login" 
           login-page="/login.htm" 
           username-parameter="username" 
           password-parameter="password" 
           authentication-failure-url="/login.htm?error=e" /> 
     <security:intercept-url pattern="/index.htm" access="hasRole('ROLE_USER')" /> 
     <security:intercept-url pattern="/addPage.htm" access="hasRole('ROLE_ADMIN')"/> 

    </security:http> 

    <!--session managment--> 
    <security:session-management> 
     <security:concurrency-control error-if-maximum-exceeded="true" max-sessions="1" /> 
    </security:session-management> 
</beans> 

Maven依賴

<dependencies> 
     <dependency> 
      <groupId>javax</groupId> 
      <artifactId>javaee-web-api</artifactId> 
      <version>7.0</version> 
      <scope>provided</scope> 
     </dependency> 
     <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-validator --> 
     <!--it's an implementation to @Validate javax interface--> 
     <dependency> 
      <groupId>org.hibernate</groupId> 
      <artifactId>hibernate-validator</artifactId> 
      <version>5.4.1.Final</version> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-webmvc</artifactId> 
      <version>4.2.0.RELEASE</version> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework</groupId> 
      <artifactId>spring-context</artifactId> 
      <version>4.2.0.RELEASE</version> 
     </dependency> 

     <dependency> 
      <groupId>javax.servlet</groupId> 
      <artifactId>servlet-api</artifactId> 
      <version>2.5</version> 
      <scope>provided</scope> 
     </dependency> 
     <!-- https://mvnrepository.com/artifact/jstl/jstl --> 
     <dependency> 
      <groupId>jstl</groupId> 
      <artifactId>jstl</artifactId> 
      <version>1.2</version> 
     </dependency> 
    </dependencies> 

回答

0

好吧,也許你應該在你的POM文件添加此相關性:

<dependency> 
    <groupId>org.springframework.security</groupId> 
    <artifactId>spring-security-web</artifactId> 
</dependency> 
<dependency> 
    <groupId>org.springframework.security</groupId> 
    <artifactId>spring-security-core</artifactId> 
</dependency> 
<dependency> 
    <groupId>org.springframework.security</groupId> 
    <artifactId>spring-security-config</artifactId> 
</dependency> 
+0

沒有東西改變:(同樣的錯誤 –

相關問題