I had the same issue get value for my property in my service class. I resolved it by using @ConfigurationProperties instead of @Value.
import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = "file")
public class FileProperties {
private String directory;
public String getDirectory() {
return directory;
}
public void setDirectory(String dir) {
this.directory = dir;
}
}
@EnableConfigurationProperties({
FileProperties.class
})