spring-mvc-test

    1熱度

    2回答

    我有一個自定義的RequestMappingHandlerMapping類,它將特殊註釋解釋爲其映射條件的一部分。它被實例化一個bean正是如此: @Configuration @EnableWebMvc public class ConfigServletConfig extends WebMvcConfigurerAdapter { @Bean public Reque

    0熱度

    1回答

    我想爲我的mvc控制器做測試,所以我知道他們工作正常。我會第一時間發佈所有的代碼,然後解釋發生了什麼事: 我的控制器 @RequestMapping(value ="Residents/create", method=RequestMethod.POST) public ResponseEntity<Object> createNewResident(@RequestBody Resident

    0熱度

    2回答

    測試1 package test.java.rest.springframework.test; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.te

    0熱度

    1回答

    我寫了一個控制器單元spting啓動@WebMvcTest配置HandlerMethodArgumentResolver。 使用@WebMvcTest,我將能夠注入MockMvc對象,如下給出: - @RunWith(SpringRunner.class) @ContextConfiguration(classes = {TestConfig.class}) @WebMvcTest clas

    0熱度

    1回答

    我正在爲SpringMvc應用程序編寫測試,並且遇到了一些問題。 這裏是我的測試控制器的方法: @RequestMapping(value = "submit", method = RequestMethod.POST, params = "delete") public String delete(@ModelAttribute("inputBean") InputBean inputBean

    0熱度

    1回答

    因此,我正在使用彈簧數據與JPA和Spring MVC使用Spring Boot編寫此Web應用程序,並且我想進行模擬控制器測試。我想出瞭如何測試get方法,但是在我的控制器post方法中,一個新的JPA實體正在被我的服務持久化或更新。以下是我的控制器看起來像: @Controller @RequestMapping("/registerMember") public class Regist

    0熱度

    1回答

    以下是我在運行Spring-Test-DBUnit時遇到的錯誤。進行集成測試時您遇到過同樣的問題嗎?你有什麼想法解決這個問題嗎?謝謝。 testCreatePerson(some project file): Failed to load ApplicationContext testHomePage(some project file): Failed to load Applicatio

    -1熱度

    1回答

    我無法將數據放入模型,因爲Spring不會將bean連接到控制器,參考是null。 Bean接口和與控制器相同的包中實現。我嘗試通過在控制器中實現ApplicationContextAware列出可用的bean(也嘗試在方法setApplicationContext中輸出到控制檯進行測試,但方法未調用,沒有輸出),但它也是null。我使用自動配置,接口的實現作爲一個bean使用,註釋爲@Compo

    1熱度

    1回答

    我正在進入SPring MVC測試框架並且無法使其工作。 當我嘗試啓動測試,得到這樣的: java.lang.IllegalStateException: Failed to load ApplicationContext at org.hibernate.cfg.beanvalidation.TypeSafeActivator.getValidatorFactory(TypeSafe

    9熱度

    1回答

    我正在使用Spring Boot 1.5.1構建非常基本的Web應用程序,並希望創建用於檢查REST端點的集成測試。根據文檔建議,可以使用MockMvc。 這是非常簡單的測試類: package foo.bar.first; import ... @RunWith(SpringRunner.class) @SpringBootTest @AutoConfigureMockMvc pu