Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 未能实例化[org.springframework.mobile.device.device]:指定的类是接口_Java_Spring_Spring Boot_Junit - Fatal编程技术网

Java 未能实例化[org.springframework.mobile.device.device]:指定的类是接口

Java 未能实例化[org.springframework.mobile.device.device]:指定的类是接口,java,spring,spring-boot,junit,Java,Spring,Spring Boot,Junit,addFreePostTest()方法测试失败。 我无法注入设备bean。 我如何解决这个问题 org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.mobile.device.Device]: Specified class is an interface BoardRestController.class @RestController @Reques

addFreePostTest()方法测试失败。 我无法注入设备bean。 我如何解决这个问题

org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.mobile.device.Device]: Specified class is an interface
BoardRestController.class

@RestController
@RequestMapping("/api/board/free")
public class BoardRestController {

    @PostMapping("")
    public FreePostWriteResponse addFreePost(
            @Valid @RequestBody FreePostForm form,
            Device device) {

    }
BoardRestControllerTests.class

@RunWith(SpringRunner.class)
@WebMvcTest(BoardRestController.class)
public class BoardRestControllerTests {

    @Autowired
    private MockMvc mvc;

    @MockBean private BoardFreeService boardFreeService;

    @Test
    @WithMockUser
    public void addFreePostTest() throws Exception {

        FreePostForm form = FreePostForm.builder()
                .subject("Subject.")
                .content("Content.")
                .categoryCode(JakdukConst.BOARD_CATEGORY_TYPE.FOOTBALL)
                .build();

        mvc.perform(post("/api/board/free")
                .contentType(MediaType.APPLICATION_JSON)
                .content(ObjectMapperUtils.writeValueAsString(form)))
                .andExpect(status().isOk());
    }

似乎有一个参数解析器没有在MockMvc配置中注册。@chrylis该解析器是DeviceWebArgumentResolver。那么如何将解析器注册到MockMvc呢?