• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

Problem with @Configurable in Spring

 
Ranch Hand
Posts: 447
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using it in the following class

I am creating an instance of the class in

The problem is that in method

of  TestRepository I am getting repository null.
I am setting up the application as follows

I think that because of '@EnableJpaRepositories("com.packtpub.springdata.jpa.repository")' above ContactRepository should be injected in TestRepository since I used '@Configurable(autowire = Autowire.BY_NAME,dependencyCheck=true)' because I am instantiating the object myself and it is not managed by Spring. @Configurable is difficult to use and I have read in some cases you must use aspectj.
 
Sheriff
Posts: 21805
104
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will say this one last time: if you use new nothing will be autowired. You need to create the beans using Spring to support autowiring.
 
Alejandro Barrero
Ranch Hand
Posts: 447
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, you have cleared my confusion after something I read about @Configurablle.
 
I like tacos! And this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!