获取“必须至少存在一个 JPA 元模型”,并@WebMvcTest
2022-09-01 20:50:35
我对Spring相当陌生,试图为一个.@Controller
@RunWith(SpringRunner.class)
@WebMvcTest(DemoController.class)
public class DemoControllerIntegrationTests {
@Autowired
private MockMvc mvc;
@MockBean
private DemoService demoService;
@Test
public void index_shouldBeSuccessful() throws Exception {
mvc.perform(get("/home").accept(MediaType.TEXT_HTML)).andExpect(status().isOk());
}
}
但我得到了
java.lang.IllegalStateException: Failed to load ApplicationContext Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: At least one JPA metamodel must be present! Caused by: java.lang.IllegalArgumentException: At least one JPA metamodel must be present!
与大多数人发布此错误不同,我不想为此使用JPA。我是否尝试使用不正确?我怎样才能找到邀请JPA参加这个派对的春天的魔力?@WebMvcTest