3

これは私の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.tachsec.src</groupId>
    <artifactId>tachsec</artifactId>    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>     <name>tachsec</name>
    <url>http://maven.apache.org</url>

    <properties>        <spring.version>3.0.5.RELEASE</spring.version>
    </properties>

    <dependencies>

        <!-- Spring 3 dependencies -->      <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>3.0.5.RELEASE</version>        </dependency>

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

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

        <dependency>            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>3.0.5.RELEASE</version>        </dependency>

        <!-- Spring Security -->        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>3.0.5.RELEASE</version>        </dependency>

        <dependency>            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>${spring.version}</version>        </dependency>

        <dependency>            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>${spring.version}</version>        </dependency>

        <!-- jstl -->       <dependency>            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>           <version>1.2</version>
        </dependency>

        <!-- MySQL database driver -->      <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.9</version>        </dependency>

    </dependencies>

    <build>         <finalName>tachsec</finalName>      <plugins>           <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>            </plugin>       </plugins>  </build>

</project>

これは私のweb.xmlです

<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <!-- The definition of the Root Spring Container shared by all
Servlets and Filters -->        <servlet>
        <servlet-name>mvc-dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>    </servlet>
    <servlet-mapping>       <servlet-name>mvc-dispatcher</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/appServlet/mvc-dispatcher-servlet.xml,
            WEB-INF/spring/appServlet/spring-database.xml,
            WEB-INF/spring/appServlet/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 です

<beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/security
    http://www.springframework.org/schema/security/spring-security-3.0.3.xsd">

    <http auto-config="true">       <intercept-url pattern="/welcome*"
access="ROLE_USER" />       <form-login login-page="/login"
default-target-url="/welcome"
            authentication-failure-url="/loginfailed" />        <logout
logout-success-url="/logout" />     </http>

    <authentication-manager>        <authentication-provider>
            <jdbc-user-service data-source-ref="dataSource"

                users-by-username-query="
                    select username,password, enabled 
                    from users where USERNAME=?"

                authorities-by-username-query="
                    select u.username, ur.authority from users u, user_roles ur 
                    where u.user_id = ur.user_id and u.username =?  " />        </authentication-provider>  </authentication-manager>

</beans:beans>

<http auto-config="true">spring-security.xml でこのエラーが発生しています。

構成の問題: spring-security-web クラスは使用できません。これらは <filter-chain-map> を使用するために必要です」

4

1 に答える 1

1

pom.xml にサーブレット ライブラリを含める必要があります。

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>{version}</version>
    <scope>provided</scope>
</dependency>
于 2013-03-13T10:10:43.080 に答える