SSM商城系統開發筆記-問題02- Error creating bean with name 'userController'


Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'userController': Unsatisfied dependency expressed through field 'userService';
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type 'com.boron.service.UserService' available: expected at least 1 bean which qualifies as autowire candidate.
Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

原因:service層沒有加注解
在搭spring mvc框架時,ide不會報錯但會有編譯錯誤的幾個注意事項:
1.controller 加注解
@RestController
@RequestMapping("/user")

2.service加注解

@Service
@Autowired
3.dao 加注解和實現接口
@Param("")




免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM