So the thing is I want to load a set of application contexts that follow the regular expression that is anything follow by -context.xml, ok?

This saves me a lot of time since I don't need to add a lot of application contexts one by one. Now, one of those application context is giving me trouble and I want it to not be included in the context configuration. Can I add something to the @ContextConfiguration annotation that removes a particular application context from the previous locations?

Is not a big nuisance, but I'm curious... Here's some code if this helps you:

@RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(locations = {
            "classpath*:resources/*-context.xml"
            })
    public class Tests{
    ...
    }
有帮助吗?

解决方案

Context exclusion is not possible in Spring. You can declare which contexts to use by using Spring Profiles. In each test you can select which profile will be used, so in turn which beans will be loaded to context.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top