The read Models attribute is null.

The configuration file is as follows:

The corresponding classes are as follows:

Using @propertysource to specify classpath:application-specialness.yml does not work.

A,

The @configurationProperties solution for loading yML files with a null value and springBoot loading custom YML files (@propertysource). @ PropertySource default does not support yml file, need new classes, inherit DefaultPropertySourceFactory, rewrite createPropertySource method.

Second,

There is another way.

Configure the spring.profiles.include property

This allows you to read the properties directly.

Reference:

1, springboot load custom yml file (@ PropertySource) 2, springboot2 @ ConfigurationProperties loading yml file appears to be obtained solution of value is null 3, spring. Profiles. include in Springboot