I updated the Spring-Data Demo App on GitHub to v0.0.2. In this version I focused on demonstrating various ways to retrieve properties to populate the DataSource connection. I didn’t plan on getting caught up in the seemingly simple process of retrieving connection properties, but Spring has so many ways to handle properties I had to dig into them a bit.
I’ll post separately on the details of handling properties in Spring that are demonstrated in v0.0.2. For now, shown below is what a successful bootRun of the new “properties demo” app section looks like.
From the display you can guess that some of the things I’ll blog about is how to override System Properties with Spring Environment properties, using the “username” system property as an example. We’re using both the Spring @Autowired Environment and @Value() approaches, each with their own configuration requirements. That will be another topic to cover. We’re also populating a “PropertyClass” from the Spring Configuration class and displaying its properties in two different classes, so I’ll touch on that as well.
From the README.md, implemented in v0.0.2
- Populating DataSource connection properties from an application.properties file
- Using both @Value and @Autowired Environment properties
- Demonstrating Annotations as well as @ImportResource of app-context.xml file
- Custom SpringPropertiesUtil Class to retrieve overriden System Properties like “username”
- Populating PropertyClass @Bean class properties in @Configuration class and displaying the properties in multiples classes
- Build: Spring 4.0.6, Spring-Boot 1.1.4
You can download Spring-Data v0.0.2 here.