如何在Junit运行时禁用swagger?- 不使用带有@profile的条件bean

oxiaedzo  于 8个月前  发布在  其他
关注(0)|答案(1)|浏览(72)

我们希望跳过Swagger来进行单元测试。
这样做的一种方法是使用条件bean,如:

@Profile("dev,qa,prod")
@Configuration

参考:https://github.com/springfox/springfox/issues/328
但是,我们不想根据个人情况而仅仅根据我们是否处于试验环境这一事实来作出这一决定。我们如何才能做到这一点?
谢谢

nwwlzxa7

nwwlzxa71#

我可以使用**@Profile({“!test && swagger”})**as:

@Configuration
@Profile({ "!test && swagger" })
@EnableSwagger2
public class SwaggerConfig {

希望有帮助。

相关问题