我正在尝试更新我的测试用例以使用@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 {
...
}
由于缺少bean java.lang.IllegalStateException: Failed to load ApplicationContext
,我不断收到错误org.springframework.security.config.annotation.ObjectPostProcessor
。
该项目是一个具有Spring安全性的RESTful应用程序。原始测试用例使用@SpringBootTest
创建了完整的Spring Boot上下文。 @DataJpaTest
应该可以帮助我测试JPA切片,这正是我想要的。
非常感谢任何帮助。我错过了什么?
答案 0 :(得分:0)
我遇到了同样的错误。
就我的情况而言,我在同一课程上添加了@SpringBootApplication
和@EnableResourceServer
。
当我将@EnableResourceServer
移到另一个配置类时,错误消失了。