-
Notifications
You must be signed in to change notification settings - Fork 5
Chapter 4 Lab
David Zemon edited this page Feb 6, 2017
·
2 revisions
The purpose of this lab is to teach you how to use Spring's Java Configuration. One bean has already been converted for you. Convert the remaining beans to Java Config and delete the XML.
- Add the beans listed below to
MainConfig.java.scannerrandomNumberGeneratorpokemonDaopokemonLocationDaopokemonFactory-
gameBoard- This bean requires a size to be imported from our properties file.
- Use
@Value("${default-map-size}") final int sizeas a parameter to thegameBoard()method - Import properties by adding
@PropertySource("...")where the argument to the annotation is the path to your properties file. Note that, in the case of multiple properties file, an array ofStrings can be used.
- Remove the XML configuration file its reference
- Remove the
@ImportResource("classpath:spring-context.xml") - Delete the XML file.
- Remove the
- Test your application
- Run
MainConfig.javaand fix any issues that might come up.
- Run