• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Problem with @Configurable in Spring

 
Ranch Hand
Posts: 501
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 22445
121
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 501
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, you have cleared my confusion after something I read about @Configurablle.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic