I am very new to Spring, reading Spring in Action 4th edition. I downloaded 4.2.2 release API, and wrote some code. When I run main method of GeometryTest, it gives NullPointerException. Why automatic wiring is not working? What am I missing? Please help.
Your Test class should be run from a Spring Unit Test runner.
You can't just do new GeometryTest() and expect Spring to auto-magically inject beans into a class that you instantiated. For Sprint to do it's Autowiring, Spring has to instantiate the bean. If you are instantitating a bean yourself, Spring isn't in the picture at all. For test classes, you do this by putting a @RunWith(SpringJUnit4ClassRunner.class) and adding test methods into your test class. You will be run your test through JUnit