Spring JUnit Test not loading full Application Context

霸气de小男生 提交于 2019-12-05 02:11:25

You need to annotate your test class with @ActiveProfiles as follows; otherwise, your Application configuration class will always be disabled. That's why you currently do not see any of your own beans listed in the ApplicationContext.

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@ActiveProfiles(Constants.SPRING_PROFILE_DEVELOPMENT)
public class MongoDbRepositoryTest { /* ... */ }

In addition, Application should be annotated with @Configuration as was mentioned by someone else.

rikica

Are you maybe missing an @Configuration annotation on your Application class?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!