代理了MaBatis Generator自动生成的Mapper的类
package com.aliapp.wxxd.material.service; import interfaces.EntityWrapperInterface; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.stereotype.Repository; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import com.aliapp.wxxd.material.entity.db.Material; import com.aliapp.wxxd.material.entity.db.MaterialCount; import com.aliapp.wxxd.material.entity.db.MaterialCountExample; import com.aliapp.wxxd.material.mapper.MaterialCountMapper; import util.FileUtil; import util.ienum.MessageTypeEnum; /** * * * @author VanXD * */ @Service public class MaterialCountMapperProxy implements MaterialCountMapper{ //注意这个接口是自动生成的,为了让Proxy与目标接口一致,所以我也实现了它<pre name="code" class="java"> @Autowired MaterialCountMapper materialCountMapper; //...
//..
}
启动TOMCAT 报错:
WARN [localhost-startStop-1] - Exception encountered during context initialization - cancelling refresh attemptorg.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘materialFacade‘: Injection of autowired dependencies failed;
nested exception isorg.springframework.beans.factory.BeanCreationException: Could not autowire field: com.aliapp.wxxd.material.service.MaterialCountMapperProxy facade.MaterialFacade.materialCountMapperProxy; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.aliapp.wxxd.material.service.MaterialCountMapperProxy] 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)} at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1202) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:762)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) at
org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4772) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1409)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1399) at java.util.concurrent.FutureTask.run(FutureTask.java:262) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
。。。
。。
。。
Spring表示没找到 MaterialCountMapperProxy 这个类的Bean,注意我是加了@Service,并且配置文件进行了扫描的。
mapper由Spring 进行扫描配置
<!-- mapper 扫描配置 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property> <property name="basePackage" value="com.aliapp.wxxd.material.mapper"></property> </bean>
扫描出来后,肯定是在IOC容器中进行了Bean的装配,就怀疑是这里有关联,所以会出错。
将
<span style="font-size:24px;">implements MaterialCountMapper</span>
去掉,TOMCAT 正常启动。
但是这样,又不能保证我的代理类的接口和Mapper的一致。。。
而如果我事务不关联这个类,又可以实现这个接口,正常启动。。。真是郁闷
版权声明:本文为博主原创文章,未经博主允许不得转载。