I find the exchange egnimatic.
>So this will look for CDPlayerConfig but your config class is empty. Please check that out >Thank you. I have figure that out. But that config class be empty is coming directly from the book referred to. It is intended to be empty for the purpose of demonstrating annotation based configuration (instead of xml based configuration). So that is no problem and the book is not mistaken. I figure it should be noted so that other readers might not be lead to think that is a problem. So "figure out"?, could well be, but definitely not something related to the emptiness of the config class!
The book provided a JUnit based testing, so a question on how to test in the appliation's main may be legitimate and sometimes useful. This is how to test the SgtPlayer part.
This will show up "Play Pink Floyd" demonstrating that the @Component effectively have the spring container instantiated an instance of SgtPlayer...
Now, your addition testing with CDPlayerTest, which seems not directly from the book, contains a problem. You have to similarly annotate the class with @Component annotation. After that, the private field CompactDise cd (CompactDisc from the book, but you did it consistently with a "e" and that's ok) will be instantiated because of the @Autowired annotation - that is the point again of the demonstration. And the test in the main will take these lines to confirm it.
And it echoes out "Yahoo..." to confirm cd being non-null. Hope this makes this thread make more sense.