【SSM】报错及解决

8 篇文章 0 订阅
6 篇文章 0 订阅

 

  • spring mvc mybatis 整合错误1

(放置事务注解的位置错误)(表现:直接访问.jsp,.html报错,写一个测试类,测试mapper,报错)
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Cannot locate BeanDefinitionDecorator for element [annotation-driven]

  • 整合错误2(dataSource拼写错误)

Offending resource: class path resource [applicationContext.xml]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'dataSouorce' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'dataSouorce' is defined

  • 整合错误3(springmvc.xml 注解驱动配置错误 修改后未解决,仍然报一下错误。注解@Service 和@Controller,仍然报错。最后直接项目删了,重新copy配置文件,问题解决了。等于说是又建了一个,autowired dependencies failed还是没有解决)    

Error creating bean with name 'itemsController': Injection of autowired dependencies failed; 
//错误的创建名为‘xxx’(原因):自动接入依赖的注入失败
nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.t.service.ItemService com.t.controller.ItemsController.itemService;
//嵌套的异常是xx.BeanCreationException(原因):不能够自动接入域:private com.t.service.ItemService ,com.t.controller.ItemsController.itemService;

 nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.t.service.ItemService] 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)}
 /*
qualifying
adj.    使具有资格的;
v.    (使) 具有资格( qualify的现在分词 ); 有权; 达标; 使所说的话语气减弱(或更具体等);
 */

 //嵌套的异常是xx..NoSuchBeanDefinitionException:没有具有资格的类型为xx的bean 被找到 为依赖:额外的在至少一个 有资格作为自动接入显而易见的bean。
 依赖注解: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

我重新copy了运行正常的项目,又遇到的这样的错误

Error creating bean with name 'itemController': Injection of autowired dependencies failed; 

可能的原因:

1.没有加@Controller,@Service

2.没有spring配置正确,扫描包配置错误。

3.我的错误是springmvc的配置文件,配置出错了。具体是.还有就是逆向工程生成的mapper。xml文件,namespace没有改

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd">

        
        
        <!-- 扫描@Controler  @Service   -->
        <context:component-scan base-package="com.t"/>
        
        <!-- 处理器映射器 -->
<!--         <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"/> -->
        <!-- 处理器适配器 -->
<!--         <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"/> -->

        <!-- 注解驱动 -->
        <!-- -- ------------------------------------------------------->
        <!-- 我的错误,写了注解驱动标签,但是conversion-service="conversionServiceFactoryBean"是没有实现的 。-->
         <!-- -- ------------------------------------------------------->
        <mvc:annotation-driven conversion-service="conversionServiceFactoryBean"/>
        
        <!-- 配置Conveter转换器  转换工厂 (日期、去掉前后空格)。。 -->
        <bean id="conversionServiceFactoryBean" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
        	<!-- 配置 多个转换器 -->
        	<property name="converters">
        		<list>
        			<bean class="com.t.conversion.DateConveter"/>
        		</list>
        	</property>
        </bean> 
        
        <!-- 视图解释器 -->
        <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        	<property name="prefix" value="/WEB-INF/jsp/"/>
        	<property name="suffix" value=".jsp"/>
        </bean>
        
   </beans>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值