转载

java – 配置问题:spring-security-web类不可用.你需要这些才能使用

我正在尝试使用Maven在我的春季网络应用程序上运行一些单元测试.该应用程序安装并运行正常,它生成一个可部署的war文件,一切正常(全部使用Maven).

我的测试类(位于src / test /java中):

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

但是我收到了错误:

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]

运行Maven时>测试

我的pom依赖被定义为

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

哪个默认编译范围, which should be OK ?当我将范围更改为测试并提供时,它返回相同的错误.

我的.classpath看起来像这样:

<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"/>

如何正确设置我的应用程序上下文和测试?

原文  https://codeday.me/bug/20190110/514104.html
正文到此结束
Loading...