i followed the tutorial posted here to get a basis application to work with Spring Data JPA. Now, how i understood, using the configuration
The problem is very probably in some of the configuration you haven't shown. It would also be good if you posted the error you're getting. It might be something different than what you think it is.
One thing I notice about your config is that you're using context:annotation-config instead of context:component-scan. The latter will auto-detect and create beans based on the @Component family of annotations. The former doesn't do that.
Other than that, everything you posted looks like it should work, though there are several odd things, which I'll come to in a moment. I copied all your posted code into a sample project and filled in a few details, like a maven pom, a persistence.xml, and the missing pieces of the applicationContext.xml. I also added a "create" method to the service so it would actually do something. With those in place and a main class to drive it all, it's a runnable example. You can browse the code on github, or you can clone and run it with:
git clone git://github.com/zzantozz/testbed tmp
cd tmp/stackoverflow/10539417-basic-spring-data-jpa
mvn -q compile exec:java -Dexec.mainClass=rds.testbed.springDataJpa.SpringDataJp
Now for the oddities that I noticed. From the top:
applicationContext.xml. It's not doing anything for you. Of course, there may well be other code that needs it that you haven't shown.@Repository annotation on your CustomerService is supposed to be used on DAO classes, or classes that interact with a database. The appropriate annotation for a service is @Service.@Resource annotation on your ICustomerRepository is mostly used for marking fields and methods for autowiring. I'm not sure what made you think to put it on your repository interface, but it's not doing anything there.@Transactional. That belongs at your service, and you've already got it there, so that's fine. Note that it still works with the @Transactional on the repository because it just joins the existing transaction started by the service.@Component-related annotation (the @Repository on your service). That might be causing you some problems. Instead of turning on component scanning, I manually created the service bean using XML in the sample project.So... if this hasn't explained something to you, if you give me a specific error, I can probably explain why you're getting it and tell you what to do to make it right.