I am trying to load custom properties from a YAML properties file upon initialization using Spring Boot. I have found countless tutorials on how to do that, and they work. The problem is that I can't seem to find a way how to instantiate POJOS, such as for example LocalDateTime. My code is as shown below.
@Configuration
@ConfigurationProperties(prefix="default-film-showings")
public class FilmShowings {
    private List<FilmShowing> filmShowings;
    //Constructors, Getters, setters etc.
    public static class FilmShowing {
        private Integer id;
        private Film film;
        private Theatre theatre;
        private LocalDateTime dateTime;
        //Constructors, Getters, setters etc.
    }
}
My YAML file is currently as follows
default-film-showings:
  filmShowings:
    - id: 1
      dateTime: 2018-07-13 21:00:00
My problem is that I get the following error upon initialisation
Failed to convert property value of type 'java.lang.String' to required type 'java.time.LocalDateTime' for property 'filmShowings[0].dateTime';
I also tried this variant
default-film-showings:
  filmShowings:
    - id: 1
      dateTime:
        date: 
          year: 2018
          month: 7
          day: 13
        time:
          hour: 21
          minute: 0
          second: 0
          nano: 0
but I got the following error
Error creating bean with name 'filmShowings': Could not bind properties to FilmShowings
Any help? I looked at the following thread JSON Java 8 LocalDateTime format in Spring Boot but it didn't solve my problem.
On a similar note, is there any way to link the Film POJO attribute to another default property?
Say I have the following in my properties file
default-films:
  films:
    - id: 1
      filmName: Spider-Man
can I add something like this too?
default-film-showings:
  filmShowings:
    - id: 1
      film: default-films.films[0]
      dateTime: whatever I need to do here to make it work
It is reading default-films.films[0] as string and thus not matching 'the YAML' object.
Any help?
 
     
    