Configuration problem: spring-security-web classes are not available. You need these to use <filter-chain-map>

╄→尐↘猪︶ㄣ 提交于 2020-01-03 09:05:11

问题


I am attempting to run some unit tests on my spring web app using Maven. The app installs and runs fine, it generates a deployable war file all OK (all using Maven).

My test class (located in src/test/java):

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"file:C:/myProjects/myWebapp/src/main/webapp/WEB-INF/applicationContext-test.xml"})
@Transactional
public class MyTest {
...

However I recieve the error :

Configuration problem: spring-security-web classes are not available. You need these to use <filter-chain-map>

Offending resource: URL [file:C:/myProjects/myWebapp/src/main/webapp/WEB-INF/applicationContext-test.xml]

When running Maven > test

My pom dependcy is defined as

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

Which defaults to compile scope, which should be OK ? It returns the same error when I change scope to test and provided.

And my .classpath looks like this:

<classpath>
    <classpathentry kind="src" output="target/classes" path="src/main/java"/>
    <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
    <classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
    <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>

How do I set-up my app context and tests correctly ?


回答1:


You have to include the Servlet library in your pom.xml :

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>{version}</version>
        <scope>provided</scope>
    </dependency>



回答2:


It's a bug of Spring Security. Include Spring Security Web to your pom.xml.

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


来源:https://stackoverflow.com/questions/7402144/configuration-problem-spring-security-web-classes-are-not-available-you-need-t

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