Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type ‘com.spring.mvc.service.UserService’ available: expected single matching bean but found 2: userServiceImpl,userService
at org.springframework.beans.factory.config.DependencyDescriptor.resolveNotUnique(DependencyDescriptor.java:217)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1215)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1164)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor
A
u
t
o
w
i
r
e
d
F
i
e
l
d
E
l
e
m
e
n
t
.
i
n
j
e
c
t
(
A
u
t
o
w
i
r
e
d
A
n
n
o
t
a
t
i
o
n
B
e
a
n
P
o
s
t
P
r
o
c
e
s
s
o
r
.
j
a
v
a
:
593
)
.
.
.
39
m
o
r
e
四
月
20
,
20196
:
50
:
46
上
午
o
r
g
.
a
p
a
c
h
e
.
c
a
t
a
l
i
n
a
.
c
o
r
e
.
A
p
p
l
i
c
a
t
i
o
n
C
o
n
t
e
x
t
l
o
g
严
重
:
S
t
a
n
d
a
r
d
W
r
a
p
p
e
r
.
T
h
r
o
w
a
b
l
e
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
b
e
a
n
s
.
f
a
c
t
o
r
y
.
U
n
s
a
t
i
s
f
i
e
d
D
e
p
e
n
d
e
n
c
y
E
x
c
e
p
t
i
o
n
:
E
r
r
o
r
c
r
e
a
t
i
n
g
b
e
a
n
w
i
t
h
n
a
m
e
′
m
a
i
n
C
o
n
t
r
o
l
l
e
r
′
:
U
n
s
a
t
i
s
f
i
e
d
d
e
p
e
n
d
e
n
c
y
e
x
p
r
e
s
s
e
d
t
h
r
o
u
g
h
f
i
e
l
d
′
u
s
′
;
n
e
s
t
e
d
e
x
c
e
p
t
i
o
n
i
s
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
b
e
a
n
s
.
f
a
c
t
o
r
y
.
N
o
U
n
i
q
u
e
B
e
a
n
D
e
f
i
n
i
t
i
o
n
E
x
c
e
p
t
i
o
n
:
N
o
q
u
a
l
i
f
y
i
n
g
b
e
a
n
o
f
t
y
p
e
′
c
o
m
.
s
p
r
i
n
g
.
m
v
c
.
s
e
r
v
i
c
e
.
U
s
e
r
S
e
r
v
i
c
e
′
a
v
a
i
l
a
b
l
e
:
e
x
p
e
c
t
e
d
s
i
n
g
l
e
m
a
t
c
h
i
n
g
b
e
a
n
b
u
t
f
o
u
n
d
2
:
u
s
e
r
S
e
r
v
i
c
e
I
m
p
l
,
u
s
e
r
S
e
r
v
i
c
e
a
t
o
r
g
.
s
p
r
i
n
g
f
r
a
m
e
w
o
r
k
.
b
e
a
n
s
.
f
a
c
t
o
r
y
.
a
n
n
o
t
a
t
i
o
n
.
A
u
t
o
w
i
r
e
d
A
n
n
o
t
a
t
i
o
n
B
e
a
n
P
o
s
t
P
r
o
c
e
s
s
o
r
AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593) ... 39 more 四月 20, 2019 6:50:46 上午 org.apache.catalina.core.ApplicationContext log 严重: StandardWrapper.Throwable org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mainController': Unsatisfied dependency expressed through field 'us'; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'com.spring.mvc.service.UserService' available: expected single matching bean but found 2: userServiceImpl,userService at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor
AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593)...39more四月20,20196:50:46上午org.apache.catalina.core.ApplicationContextlog严重:StandardWrapper.Throwableorg.springframework.beans.factory.UnsatisfiedDependencyException:Errorcreatingbeanwithname′mainController′:Unsatisfieddependencyexpressedthroughfield′us′;nestedexceptionisorg.springframework.beans.factory.NoUniqueBeanDefinitionException:Noqualifyingbeanoftype′com.spring.mvc.service.UserService′available:expectedsinglematchingbeanbutfound2:userServiceImpl,userServiceatorg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessorAutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1378)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:575)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:498)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
解决方法:
<!-- mapper动态代理开发 ,使用MyBatis基于注解的方式对数据集操作 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.spring.mvc.dao"></property>
</bean>