Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 965275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:58:13+00:00 2026-05-16T01:58:13+00:00

When trying to autowire JdbcUserDetailsManager from Spring Security, I use following statement in appcontext.xml

  • 0

When trying to autowire JdbcUserDetailsManager from Spring Security, I use following statement in appcontext.xml (located separated from webapp):

 <bean class="org.springframework.security.provisioning.JdbcUserDetailsManager">
    <property name="dataSource" ref="dataSource"/>                                                                
</bean>

When running unit test all is fine. When starting my web app, which has it’s own appcontext.xml including the original appcontext.xml, I get an duplicate error:

No unique bean of type 
    [org.springframework.security.provisioning.JdbcUserDetailsManager] is defined:   
        expected single matching bean but found 2: 
    [org.springframework.security.provisioning.JdbcUserDetailsManager#0, 
        org.springframework.security.provisioning.JdbcUserDetailsManager#1]

How can I refine my two appcontext.xml in order to get both, the service layer tests and the webapp running respectively?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T01:58:14+00:00Added an answer on May 16, 2026 at 1:58 am

    Why do you need to include the JdbcUserDetailsManager in your web/servlet application context? The WebApplicationContext gets the main ApplicationContext as a parent “automatically” (if you configure it correctly.) See this IBM article for an example of setting contextConfigLocation so the web app knows where to find the main ApplicationContext.

    Or this example:

    contextConfigLocation
    /WEB-INF/main-application-config.xml

        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
        <servlet>
            <servlet-name>mine</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/web-application-config.xml</param-value>
            </init-param>
        </servlet>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to autowire up my application using Autofac. All is fine apart from
I'm trying to use Spring to inject a SLF4J logger into a class like
I am trying to get a Java app using spring-security to talk to a
I'm trying to autowire a bean in the MVC Controller class, but I can
I'm trying to autowire a mocked DAO object for my Spring (v. 3.1.0.RELEASE) test
Trying to auto-wire properties to a bean in Spring 3.0.5.RELEASE , I'm using: config.properties
I am trying to enable Spring autowiring support in my webservice, following the lines
I have a class that uses a method from a bean. I'm trying to
I am trying to autowire some beans (for dependency injection) using Spring for a
I am trying to use Spring with Scala. I know Autowired works with Scala

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.