java - How to inject spring injection manually if not done automatically -


My spring dependency is working fine but there is a square

CustomUserDetaisls To match the username and password

  @Autowired Private UserDAO userDAO   

but my spring injection I'm not working here because it applies class userDetailsSerivce Although injection works if I pulled out the tools.

Why have I asked the question to ask, but no one has given me the answer, so I decided to use the DAO with the new operator

  Personal Usageo Userdao = New user ();   

But that depends on the session factory, which is a spring bean, in exchange for UserDo .

Configure ("Com / Voices / Services / Hibernate Cfg .xml") .buildSessionFactory ();

But again I have many beans in the hibernate context, such as data sources, property files, and I am finding it very difficult to rewrite all the things.

Can I manually inject the userDAO in any way so that all related spring injection sessions practice work

You can take a look at the Spring Java configuration.

The examples below all dependencies of Userdoes will be automatically set to spring. This should be something like this:

  @configuration @ Property Soros ("Classpath: Configuration. Properties") Public class ApplicationConfig {@ Ben Public Username user ()) Return new user (); } @ Beynes Public Control User Custom User Details (UserUserDio) {Custom User Display Custom UserDayfiles = New Custom User Details (); CustomUserDetails.setUserDAO (userDAO ()); Return Custom User; description; }}    

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -