小编Lak*_*o12的帖子

我在 Spring 安全测试中遇到 stackOverflowError

安全配置类

@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConf {

    @Bean
    public AuthenticationManager authenticationManagerBean(AuthenticationConfiguration authenticationConfiguration) throws Exception {
        return authenticationConfiguration.getAuthenticationManager();
    }

}
Run Code Online (Sandbox Code Playgroud)

控制器

@RestController
public class Controller {
    
    @GetMapping("/test")
    public String test(){
        return "test";
    }
}
Run Code Online (Sandbox Code Playgroud)

测试班

@ExtendWith(SpringExtension.class)
@WebMvcTest(controllers = Controller.class)
@ComponentScan("com.example.demo")
public class DemoApplicationTests {

    @Test
    public void test() {
    }
}
Run Code Online (Sandbox Code Playgroud)

我有一个简单的应用程序,如果我尝试启动主应用程序,它可以工作,但是当我启动测试类时,我收到此错误:

java.lang.StackOverflowError
            at java.base/java.lang.StackTraceElement.of(StackTraceElement.java:526)
            at java.base/java.lang.Throwable.getOurStackTrace(Throwable.java:828)
            at java.base/java.lang.Throwable.getStackTrace(Throwable.java:820)
            at ch.qos.logback.classic.spi.ThrowableProxy.<init>(ThrowableProxy.java:79)
            at ch.qos.logback.classic.spi.ThrowableProxy.<init>(ThrowableProxy.java:89)
            at ch.qos.logback.classic.spi.ThrowableProxy.<init>(ThrowableProxy.java:89)
            at ch.qos.logback.classic.spi.ThrowableProxy.<init>(ThrowableProxy.java:89)
            at ch.qos.logback.classic.spi.ThrowableProxy.<init>(ThrowableProxy.java:89)
            at ch.qos.logback.classic.spi.ThrowableProxy.<init>(ThrowableProxy.java:89)
            at ch.qos.logback.classic.spi.ThrowableProxy.<init>(ThrowableProxy.java:89)
            at ch.qos.logback.classic.spi.ThrowableProxy.<init>(ThrowableProxy.java:89)
            at ch.qos.logback.classic.spi.ThrowableProxy.<init>(ThrowableProxy.java:89)
            at ch.qos.logback.classic.spi.ThrowableProxy.<init>(ThrowableProxy.java:89) …
Run Code Online (Sandbox Code Playgroud)

java spring-security spring-test maven spring-boot

6
推荐指数
1
解决办法
1437
查看次数

标签 统计

java ×1

maven ×1

spring-boot ×1

spring-security ×1

spring-test ×1