Springboot 2.0.5 搭建一个新项目启动后报错:Bean named 'xxxService'... but was actually of type 'com.sun.proxy.$Proxy82'
C:Javajdk1.8.0_144injava.exe -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=12905 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:C:JetBrainsIntelliJ IDEA 2018.2.2libidea_rt.jar=12906:C:JetBrainsIntelliJ IDEA 2018.2.2in" -Dfile.encoding=UTF-8 -classpath
.......
. ____ _ __ _ _
/\ / ___'_ __ _ _(_)_ __ __ _
( ( )\___ | '_ | '_| | '_ / _` |
\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.0.5.RELEASE)
2018-10-17 00:35:21,936 INFO (Jdk14Logger.java:87)- Root WebApplicationContext: initialization completed in 1464 ms
_ _ |_ _ _|_. ___ _ | _
| | |/|_)(_| | |_ |_)||_|_
/ |
3.0.5
2018-10-17 00:35:22,328 WARN (Jdk14Logger.java:87)- Exception encountered during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'articleController':
Unsatisfied dependency expressed through field 'articleService';
nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException:
Bean named 'articleService' is expected to be of type 'com.test.demo.elastic.service.impl.ArticleServiceImpl'
but was actually of type 'com.sun.proxy.$Proxy82'
Process finished with exit code 1
后来想起pom.xml 文件中忘了加 aop 的依赖了…
pom.xml 中添加依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>