Java Spring安全返回404错误

Java Spring安全返回404错误,java,spring,eclipse,web-applications,spring-security,Java,Spring,Eclipse,Web Applications,Spring Security,我正在开发一个简单的spring安全模块,但它使用apache tomcat 9.0返回404错误。以下是我的代码: applicationContext.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:

我正在开发一个简单的spring安全模块,但它使用apache tomcat 9.0返回404错误。以下是我的代码:

applicationContext.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:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/security 
http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd">

<security:user-service id="userService">
    <security:user name="user1" password="secret" authorities="ROLE_USER"/>
    <security:user name="user2" password="secret" authorities="ROLE_USER,ROLE_EDITOR"/>
</security:user-service>

<security:authentication-manager>
    <security:authentication-provider user-service-ref="userService"/>
</security:authentication-manager>

<security:http pattern="/favicon.ico" security="none"/>

<security:http auto-config="true">
    <security:intercept-url pattern="/**" access="ROLE_USER"/>
</security:http>
`
`

web.xml `


Web应用程序创建的原型
springSecurityFilterChain
org.springframework.web.filter.DelegatingFilterProxy
springSecurityFilterChain
/*
org.springframework.web.context.ContextLoaderListener
`

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.willey.beginningspring.ch11</groupId>
  <artifactId>spring-book-ch12</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>spring-book-ch12 Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>

    <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-core</artifactId>
    <version>3.2.0.RELEASE</version>
    </dependency>

    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-web</artifactId>
      <version>3.2.0.RELEASE</version>
    </dependency>

     <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-config</artifactId>
      <version>3.2.0.RELEASE</version>
    </dependency>

  </dependencies>
  <build>
    <finalName>spring-book-ch12</finalName>
  </build>
</project>

4.0.0
com.willey.beginingspring.ch11

我正在使用apache server 9运行该项目,但遇到如下404错误:

源服务器找不到目标资源的当前表示形式,或者不愿意透露存在该表示形式


我想测试spring的安全性,并在互联网上搜索了很多问题,但对我来说不起作用。请提供帮助。

我在像eclipse这样的IDE上使用tomcat 9时遇到问题。。您是否使用tomcat 8尝试过同样的方法?因为我也遇到过类似的问题,它出现在tomcat 8上,不确定这是否是问题的原因,但仍然..我切换到tomcat v8.0,但这次的错误不同:请求的资源不可用。使用>=8.5 tomcat版本
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.willey.beginningspring.ch11</groupId>
  <artifactId>spring-book-ch12</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>spring-book-ch12 Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>

    <dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-core</artifactId>
    <version>3.2.0.RELEASE</version>
    </dependency>

    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-web</artifactId>
      <version>3.2.0.RELEASE</version>
    </dependency>

     <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-config</artifactId>
      <version>3.2.0.RELEASE</version>
    </dependency>

  </dependencies>
  <build>
    <finalName>spring-book-ch12</finalName>
  </build>
</project>