org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'cn.fang.service.UserService' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
这个错误的原因是,需要加上注解的类没有加上注解。在完成ssm时
在controller类加上注解@Controller注解,表示控制类
在service的实现类serviceImpl上呀叫上注解
@Service("写上业务层service的对象名")
表示事务的注解
@Transactional
我没有在实现类上加上注解
@Service("userService")
@Transactional
然后问题就解决了。
有时候当你修改代码之后,然后在发布tomcat。可能还是不能实现。这时你需要将tomcat里面的项目移除然后在重新发布即可