繁体   English   中英

在spring boot MVC测试中自定义bean

[英]customize beans in spring boot MVC test

我使用的是Spring-boot 1.4.0.RELEASE。 按照建议构建了一个MVC int测试

https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html#boot-features-testing-spring-boot-applications-testing-autoconfigured-mvc-tests

但是,我找不到在那里自定义objectMapper的好方法。 在我的生产配置中,我使用@Primary注释了Bean。 在那里定义了objectmapper有一些自定义,我真的想在MVC测试中包含该配置。 但我找不到一个好方法。

如果有人能在那里发光,我将非常感激

使用@TestConfiguration根据集成测试中的需要配置objectmapper

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM