Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring安全性,错误bean过滤器链_Java_Spring - Fatal编程技术网

Java Spring安全性,错误bean过滤器链

Java Spring安全性,错误bean过滤器链,java,spring,Java,Spring,首先我想为我的英语道歉。我只是学英语 我刚开始学习Spring Security,遇到了一些麻烦。我读了以前的科目,但我并没有解决这个问题 错误如下所示: <annotation-driven /> <resources mapping="/resources/**" location="/resources/" /> <beans:bean class="org.springframework.web.servle

首先我想为我的英语道歉。我只是学英语

我刚开始学习Spring Security,遇到了一些麻烦。我读了以前的科目,但我并没有解决这个问题

错误如下所示:

<annotation-driven />
<resources mapping="/resources/**" location="/resources/" />
<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="pl.myproject.controller" />
</beans:beans>
<http auto-config="true">
        <intercept-url pattern="/" access="ROLE_USER" />
    </http>
 
    <authentication-manager>
      <authentication-provider>
        <user-service>
        <user name="dejmien" password="qwert" authorities="ROLE_USER" />
        </user-service>
      </authentication-provider>
    </authentication-manager>
<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
  
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value> /WEB-INF/spring/root-context.xml,  /WEB-INF/spring/spring-security.xml</param-value>
  </context-param>
        

    
    <!-- Spring Security -->
    <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>
  
</web-app>
创建名为“org.springframework.security.filterChains”的bean时出错:无法解析对bean“org.springframework.security.web.DefaultSecurityFilterChain”的引用

创建名为“(内部bean)#2”的bean时出错:bean实例化失败;嵌套的异常是java.lang.NoClassDefFoundError:org/springframework/web/context/request/async/CallableProcessingInterceptor

myservlet-context.xml:

<annotation-driven />
<resources mapping="/resources/**" location="/resources/" />
<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="pl.myproject.controller" />
</beans:beans>
<http auto-config="true">
        <intercept-url pattern="/" access="ROLE_USER" />
    </http>
 
    <authentication-manager>
      <authentication-provider>
        <user-service>
        <user name="dejmien" password="qwert" authorities="ROLE_USER" />
        </user-service>
      </authentication-provider>
    </authentication-manager>
<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
  
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value> /WEB-INF/spring/root-context.xml,  /WEB-INF/spring/spring-security.xml</param-value>
  </context-param>
        

    
    <!-- Spring Security -->
    <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>
  
</web-app>

spring-security.xml:

<annotation-driven />
<resources mapping="/resources/**" location="/resources/" />
<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="pl.myproject.controller" />
</beans:beans>
<http auto-config="true">
        <intercept-url pattern="/" access="ROLE_USER" />
    </http>
 
    <authentication-manager>
      <authentication-provider>
        <user-service>
        <user name="dejmien" password="qwert" authorities="ROLE_USER" />
        </user-service>
      </authentication-provider>
    </authentication-manager>
<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
  
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value> /WEB-INF/spring/root-context.xml,  /WEB-INF/spring/spring-security.xml</param-value>
  </context-param>
        

    
    <!-- Spring Security -->
    <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>
  
</web-app>

web.xml:

<annotation-driven />
<resources mapping="/resources/**" location="/resources/" />
<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="pl.myproject.controller" />
</beans:beans>
<http auto-config="true">
        <intercept-url pattern="/" access="ROLE_USER" />
    </http>
 
    <authentication-manager>
      <authentication-provider>
        <user-service>
        <user name="dejmien" password="qwert" authorities="ROLE_USER" />
        </user-service>
      </authentication-provider>
    </authentication-manager>
<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
  
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
  
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value> /WEB-INF/spring/root-context.xml,  /WEB-INF/spring/spring-security.xml</param-value>
  </context-param>
        

    
    <!-- Spring Security -->
    <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>
  
</web-app>

appServlet
org.springframework.web.servlet.DispatcherServlet
上下文配置位置
/WEB-INF/spring/appServlet/servlet-context.xml
1.
appServlet
/
org.springframework.web.context.ContextLoaderListener
上下文配置位置
/WEB-INF/spring/root-context.xml,/WEB-INF/spring/spring-security.xml
springSecurityFilterChain
org.springframework.web.filter.DelegatingFilterProxy
springSecurityFilterChain
/*
我放置pom.xml文件:

<modelVersion>4.0.0</modelVersion>
    <groupId>pl.myproject</groupId>
    <artifactId>controller</artifactId>
    <name>Hairdrss Project</name>
    <packaging>war</packaging>
    <version>1.0.0-BUILD-SNAPSHOT</version>
    <properties>
        <java-version>1.6</java-version>
        <org.springframework-version>3.1.1.RELEASE</org.springframework-version>
        <org.aspectj-version>1.6.10</org.aspectj-version>
        <org.slf4j-version>1.6.6</org.slf4j-version>
    </properties>
    <dependencies>
        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework-version}</version>
            <exclusions>
                <!-- Exclude Commons Logging in favor of SLF4j -->
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                 </exclusion>
            </exclusions>
        </dependency>
        
        
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>
                
        <!-- AspectJ -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>${org.aspectj-version}</version>
        </dependency>   
        
        
        <!-- Spring Security -->
        
        
          <dependency>  
   <groupId>org.springframework.security</groupId>  
   <artifactId>spring-security-core</artifactId>  
   <version>3.2.3.RELEASE</version>  
  </dependency>
    
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>3.2.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>3.2.3.RELEASE</version>
    </dependency>



        
        
        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${org.slf4j-version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.15</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.mail</groupId>
                    <artifactId>mail</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.jms</groupId>
                    <artifactId>jms</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jdmk</groupId>
                    <artifactId>jmxtools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jmx</groupId>
                    <artifactId>jmxri</artifactId>
                </exclusion>
            </exclusions>
            <scope>runtime</scope>
        </dependency>

        <!-- @Inject -->
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>
                
        <!-- Servlet -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
    
        <!-- Test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </dependency>        
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <additionalProjectnatures>
                        <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                    </additionalProjectnatures>
                    <additionalBuildcommands>
                        <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                    </additionalBuildcommands>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArgument>-Xlint:all</compilerArgument>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <configuration>
                    <mainClass>org.test.int1.Main</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
4.0.0
pl.myproject
控制器
Hairdrss项目
战争
1.0.0-BUILD-SNAPSHOT
1.6
3.1.1.1发布
1.6.10
1.6.6
org.springframework
spring上下文
${org.springframework版本}
公用记录
公用记录
org.springframework
SpringWebMVC
${org.springframework版本}
org.aspectj
aspectjrt
${org.aspectj版本}
org.springframework.security
spring安全内核
3.2.3.1发布
org.springframework.security
spring安全网
3.2.3.1发布
org.springframework.security
spring安全配置
3.2.3.1发布
org.slf4j
slf4j api
${org.slf4j版本}
org.slf4j
jcl-over-slf4j
${org.slf4j版本}
运行时
org.slf4j
slf4j-log4j12
${org.slf4j版本}
运行时
log4j
log4j
1.2.15
javax.mail
邮件
javax.jms
jms
com.sun.jdmk
jmxtools
com.sun.jmx
jmxri
运行时
javax.inject
javax.inject
1.
javax.servlet
servlet api
2.5
假如
javax.servlet.jsp
jsp api
2.1
假如
javax.servlet
jstl
1.2
朱尼特
朱尼特
4.7
测试
maven eclipse插件
2.9
org.springframework.ide.eclipse.core.springnature
org.springframework.ide.eclipse.core.springbuilder
真的
真的
org.apache.maven.plugins
maven编译器插件
2.5.1
1.6
1.6
-Xlint:全部
真的
真的
org.codehaus.mojo
execmaven插件
1.2.1
org.test.int1.Main

我猜您正在混合不同spring版本的罐子,或者缺少一个罐子。请将您的依赖项/JAR列表添加到帖子中。您是对的。。。我将spring版本更改为3.2.3 realse,程序运行。Thx!!!!@M.Deinum:我建议你把它改写成一个答案,这样问题就不会一直没有回答。@M.Deinum Serge我也面临同样的问题。但我无法更新版本,因为它是一个旧项目。哪个版本的spring security与spring 3.1.3.0版本兼容?