0

I have an application with an application.yml, but I want another configuration file by the name foo.yml. I can't seem to get it to work. What's wrong with my code?

@ConfigurationProperties(prefix = "test")
@Configuration
@PropertySource(value = "classpath:foo.yml")
public class All {
    String oof;
    // getters and setters and toString
}

My foo.yml

test:
    oof: "bloof"

My test, where oof outputs as null instead of bloof

@ExtendWith(SpringExtension.class)
@SpringBootTest
class AllTest {

    @Autowired
    private All all;

    @Test
    public void test {
        System.out.println(all.toString());
    }
}
Hackerman
  • 1,289
  • 1
  • 14
  • 29

1 Answers1

1

Because .yml is not supported by @PropertySource(value=..) From doc:

Both traditional and XML-based properties file formats are supported — for example, "classpath:/com/myco/app.properties" or "file:/path/to/file.xml".

夢のの夢
  • 5,054
  • 7
  • 33
  • 63