开发者社区> 问答> 正文

springMvc Test?报错

maven 项目

测试类部分代码

@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration(value = "src/main/webapp")
@ContextConfiguration(locations={"classpath*:/beans.xml"}) 
public class UserControllerTest {


@Autowired  
    private WebApplicationContext wac;  
    private MockMvc mockMvc; 
    
    @Before  
    public void setUp() {   
        this.mockMvc = webAppContextSetup(this.wac).build();  
    } 
    
    @Test  
    public void testList() throws Exception {  
        mockMvc.perform((get("/user/list"))); 
    }
}
运行后报错:

    Circular view path [list]: would dispatch back to the current handler URL [/user/list] again. Check your ViewResolver setup! 

搜了很多,也没找到答案。就来这里问问,帮帮忙!!!

刚接触springmvc的测试,不是很了解。

感觉好像没有加载springmvc的配置文件,还是不用加载啊!网上给的例子跟上面的代码差不多!

展开
收起
爱吃鱼的程序员 2020-06-09 15:28:57 471 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    我知道原因了,对于我这种情况,我没有把springmvc的配置文件放入到classpath中!!!

    2020-06-09 15:29:15
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载