Classpath Wildcard In @PropertySource

- 1 answer

I am using Spring Java config to create my bean. But this bean is common to 2 applications. Both have one property file but with different classpath locations. When i put explicit classpath like


then it works but when i try to use wildcard like


then it doesn't work. I try many combinations of wildcard but it still not working. Is wildcard works in @ProeprtySource Is there any other way to read to property in classed marked with @Configurations.



@PropertySource API: Resource location wildcards (e.g. **/*.properties) are not permitted; each location must evaluate to exactly one .properties resource.

workaround: try

public class Test {

    public PropertyPlaceholderConfigurer getPropertyPlaceholderConfigurer()
            throws IOException {
        PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
        ppc.setLocations(new PathMatchingResourcePatternResolver().getResources("classpath:/**/"));
        return ppc;