发表于: 2017-05-22 21:28:16

1 1325


今日完成:

编写SpringMVC


遇到问题:

解决网页404的问题,

报错

 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.elin4it.ssm.service.UserService com.elin4it.ssm.controller.UserController.userService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.elin4it.ssm.service.UserService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

出现上述问题的原因是没有在相应的实现类中追加相应的注解。

发现的问题是在Service层的实现类中没有追加:

@Service("XXXXX")

在service的实现类XXXXXServiceImpl.java的开始,追加@Service("XXXXX"),如下:

@Service("XXXXX")

public class XXXXXServiceImpl implements XXXXXService{

......

}

另外一个项目报错

23-May-2017 01:22:18.540 严重 [http-nio-8080-exec-3] org.apache.catalina.core.StandardWrapperValve.invoke Allocate exception for servlet [mvc-dispatcher]

 org.xml.sax.SAXParseException; lineNumber: 57; columnNumber: 69; cvc-complex-type.2.4.c: 通配符的匹配很全面, 但无法找到元素 'tx:annotation-driven' 的声明。

解决办法:

在声明文件最后加上这段就可以了

 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd


明天计划:

编写SSM框架


收获:

解决了BUG问题,项目运行起来 立马就有劲了,遇到报错要多搜索,解决不了,及时反馈给师兄,




返回列表 返回列表
评论

    分享到