Note that there are some explanatory texts on larger screens.

plurals
  1. POAutowire doesnt wire custom UserDetailsService
    primarykey
    data
    text
    <p>I have defined Custom <code>UserDetailService</code> named as <code>UserService</code> and it works fine. When i autowire it in some bean it gives me error </p> <pre><code>org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.restaurant.service.UserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} </code></pre> <p>I have check all answered solution related to this on this forum but it didnt helped me to resolve my issue so i am posting the question again.</p> <p>In my <code>rootcontext.xml</code> i have included "<code>context:annotation-config</code>" tag and in my <code>webcontext.xml</code> i have included <code>"context:component-scan base-package="com.restaurant""</code> . I also observed that the default constructor of <code>UserService</code> is getting called on server startup. But still autowiring it into other bean does not work. All other autowire works except custom <code>UserDetailService</code>.</p> <p>Can anybody help me to resolve it as i m totally lost into this problem.</p> <p>My Custom UserService class looks like:</p> <pre><code>@Service public class UserService implements UserDetailsService { @Autowired private UserDAO userDAO; public UserDetails loadUserByUsername(String username)throws UsernameNotFoundException, DataAccessException { User user = userDAO.findUnique("select usr from User usr where usr.isActive = 1 and usr.userName = ?", username); if(user == null) { throw new UsernameNotFoundException("User not found"); } return user; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload