title: NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.security.authentication.AuthenticationManager] found for dependency
body: <p>I am trying to load applicationContext.xml manually which removing previous autowired if i do not load the applicationContext.xml previous code works fine. </p>
  
  <pre><code>Error :  Request processing failed; nested exception is 
  org.springframework.beans.factory.BeanCreationException: Error 
  creating bean with name 'securityServiceImpl': Injection of autowired 
  dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not 
  autowire field: private org.springframework.security.authentication.AuthenticationManager 
  com.visualpathit.account.service.SecurityServiceImpl.authenticationManager;nested exception is  org.springframework.beans.factory.NoSuchBeanDefinitionException: No 
  qualifying bean of type 
  [org.springframework.security.authentication.AuthenticationManager] 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>ApplicationContext.xml </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:int="http://www.springframework.org/schema/integration"
  xmlns:int-amqp="http://www.springframework.org/schema/integration/amqp"
  xmlns:rabbit="http://www.springframework.org/schema/rabbit"
  xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans.xsd
  http://www.springframework.org/schema/integration
  http://www.springframework.org/schema/integration/spring-tegration.xsd
  http://www.springframework.org/schema/integration/amqp 
  http://www.springframework.org/schema/integration/amqp/spring-
  integration-amqp.xsd
  http://www.springframework.org/schema/rabbit 
  http://www.springframework.org/schema/rabbit/spring-rabbit.xsd
  http://www.springframework.org/schema/context 
  http://www.springframework.org/schema/context/spring-context.xsd"&gt;
  
  &lt;context:annotation-config/&gt;
  &lt;!-- Configuration for Component Scan --&gt;
  &lt;context:component-scan base-package="com.visualpathit.account" /&gt;  
  &lt;context:property-placeholder 
  location="classpath*:rabbitmq.properties"/&gt;
  &lt;int:channel id="inputChannel"/&gt;
  &lt;int:gateway id="orderGateway" service-
  interface="com.visualpathit.account.repository.OrderGateway" default-
  request-channel="inputChannel" /&gt;  
  &lt;int-amqp:channel id="processChannel"
  connection-factory="connectionFactory" 
  message-driven="true"
  queue-name="ha.rabbit.channel" /&gt;   
  &lt;rabbit:connection-factory id="connectionFactory"  
  addresses="${rabbitmq.addresses}" username="${rabbitmq.username}"    
  password="${rabbitmq.password}" /&gt; 
  
  &lt;int:splitter id="orderSplitter" input-channel="inputChannel" 
  output-channel="processChannel" /&gt;
  &lt;int:service-activator input-channel="processChannel" 
  ref="orderProcessService" method="process" /&gt;  
  &lt;/beans&gt;
  </code></pre>
  
  <p>Controller code:</p>
  
  <pre><code>    @RequestMapping(value = { "/user/rabbit"} , method = RequestMethod.GET)    
  public static String rabbitmqSetUp(){
  orderGateway = context.getBean(OrderGateway.class);  
  try {
  ----
  } catch (InterruptedException e) {
  Thread.currentThread().interrupt();
  }
  return "welcome";
  }
  </code></pre>
  
  <p>SecurityServiceImpl</p>
  
  <pre><code>@Service
  public class SecurityServiceImpl implements SecurityService {
  /** authenticationManager !*/
  @Autowired
  private AuthenticationManager authenticationManager;
  /** userDetailsService !*/
  @Autowired
  private UserDetailsService userDetailsService;
  
  /** Logger creation !*/
  private static final Logger logger = 
  LoggerFactory.getLogger(SecurityServiceImpl.class);
  @Override
  public String findLoggedInUsername() {
      Object userDetails = SecurityContextHolder.getContext()
                          .getAuthentication().getDetails();
      if (userDetails instanceof UserDetails) {
          return ((UserDetails) userDetails).getUsername();
      }
  
      return null;
  }
  </code></pre>