Producing Twitter credentials

We will use the @Configuration class to provide our Twitter configuration objects. The @Configuration class is really good to provide infrastructure beans, if we do not have starter projects for the required module.

Also, we will use the application.yaml file to store the Twitter credentials. This kind of configuration should not be kept in the source code repository because it is sensitive data and should not be shared with others. Then, the Spring Framework enables us to declare properties in the yaml file and configures the environment variables to fill these properties at runtime. It is an excellent way to keep sensitive data out of the source code repository.

Get Spring 5.0 By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.