Chr*_*r Z 6 java testing spring-security spring-boot
我正在尝试更新我的测试用例以使用@DataJpaTest.但是,我遇到了一些似乎与Spring Security相关的问题.以下是测试类的示例.
@RunWith(SpringRunner.class)
@DataJpaTest
public class ExampleRepositoryTest {
@Rule
public final ExpectedException exception = ExpectedException.none();
@Inject
private ExampleRepository repository;
@Test
public void test() throws Exception {
...
}
Run Code Online (Sandbox Code Playgroud)
java.lang.IllegalStateException: Failed to load ApplicationContext由于缺少bean,我不断收到错误org.springframework.security.config.annotation.ObjectPostProcessor.
该项目是一个带有Spring安全性的RESTful应用程序.原始测试用例使用创建了完整的Spring Boot上下文@SpringBootTest.这@DataJpaTest应该可以帮助我测试JPA切片,这正是我想要的.
任何帮助将不胜感激.我错过了什么?
小智 0
我遇到了同样的错误。对于我的情况,我在同一类上添加了@SpringBootApplication和。@EnableResourceServer当我移动@EnableResourceServer到另一个配置类时,错误就消失了。
| 归档时间: |
|
| 查看次数: |
715 次 |
| 最近记录: |