BeanNotOfRequiredTypeException due to autowired fields

前端 未结 9 1277
长发绾君心
长发绾君心 2020-12-02 12:07

I\'m still new to Spring MVC and while building my test project, I got this message from Tomcat logs:

SEVERE: Exception sending context initialized event to          


        
9条回答
  •  孤街浪徒
    2020-12-02 12:54

    I just experienced this issue when a test on an existing class started failing with 'expected to be of type...but was actually of type 'com.sun.proxy.$Proxy115'.

    What it turned out to be was that I had used Intellij's 'pull method up [to interface]' on an @Transactional method that I had added to the interface's implementation class, and Intellij decided to add @Transactional to the interface method declaration. If there is just one @Transactional method in an interface then it seems to screw things up, resulting in this error.

提交回复
热议问题