困扰多时-注解出错,这个框架接触不久,按照前人的配置方式配置后出该问题

问题描述

注解出错,这个框架接触不久,按照前人的配置方式配置后出该问题

11:29:59.477 ERROR org.springframework.web.servlet.DispatcherServlet - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping#0' defined in ServletContext resource [/WEB-INF/config/jeecms-servlet-front.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'applyAct': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.jeecms.dzpt.manager.ApplyMng com.jeecms.dzpt.action.ApplyAct.applyMng; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.jeecms.dzpt.manager.ApplyMng] 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.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527) ~[spring.beans-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456) ~[spring.beans-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291) ~[spring.beans-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring.beans-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288) ~[spring.beans-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194) ~[spring.beans-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:398) ~[spring.beans-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBeansOfType(AbstractApplicationContext.java:1146) ~[spring.context-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:275) ~[spring.beans-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.initHandlerMappings(DispatcherServlet.java:424) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.initStrategies(DispatcherServlet.java:339) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.DispatcherServlet.onRefresh(DispatcherServlet.java:328) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.onApplicationEvent(FrameworkServlet.java:523) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet$ContextRefreshListener.onApplicationEvent(FrameworkServlet.java:749) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet$ContextRefreshListener.onApplicationEvent(FrameworkServlet.java:1) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.context.event.GenericApplicationListenerAdapter.onApplicationEvent(GenericApplicationListenerAdapter.java:51) ~[spring.context-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.context.event.SourceFilteringListener.onApplicationEventInternal(SourceFilteringListener.java:97) ~[spring.context-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.context.event.SourceFilteringListener.onApplicationEvent(SourceFilteringListener.java:68) ~[spring.context-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97) ~[spring.context-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:303) ~[spring.context-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:911) ~[spring.context-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:428) ~[spring.context-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:442) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:458) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:339) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:306) ~[spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127) [spring.web.servlet-3.0.5.jar:3.0.5.RELEASE]
at javax.servlet.GenericServlet.init(GenericServlet.java:212) [servlet-api.jar:2.5.MR2]
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1213) [catalina.jar:6.0.44]
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1026) [catalina.jar:6.0.44]
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4425) [catalina.jar:6.0.44]
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4738) [catalina.jar:6.0.44]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:802) [catalina.jar:6.0.44]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779) [catalina.jar:6.0.44]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:583) [catalina.jar:6.0.44]
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1080) [catalina.jar:6.0.44]
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1003) [catalina.jar:6.0.44]
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:507) [catalina.jar:6.0.44]
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1322) [catalina.jar:6.0.44]
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:325) [catalina.jar:6.0.44]
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142) [catalina.jar:6.0.44]
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1068) [catalina.jar:6.0.44]
at org.apache.catalina.core.StandardHost.start(StandardHost.java:822) [catalina.jar:6.0.44]
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1060) [catalina.jar:6.0.44]
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463) [catalina.jar:6.0.44]
at org.apache.catalina.core.StandardService.start(StandardService.java:525) [catalina.jar:6.0.44]
at org.apache.catalina.core.StandardServer.start(StandardServer.java:759) [catalina.jar:6.0.44]
at org.apache.catalina.startup.Catalina.start(Catalina.java:595) [catalina.jar:6.0.44]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_43]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_43]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_43]
at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_43]
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) [bootstrap.jar:6.0.44]
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) [bootstrap.jar:6.0.44]

解决方案

这个应该是springmvc吧,,看下你的配置

解决方案二:

<?xml version="1.0" encoding="UTF-8"?>
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
default-lazy-init="true">

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>/WEB-INF/config/jdbc.properties</value>
        </list>
    </property>
</bean>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <property name="driverClass" value="${jdbc.driverClassName}" />
    <property name="jdbcUrl" value="${jdbc.url}" />
    <property name="user" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
    <property name="autoCommitOnClose" value="true"/>
    <property name="checkoutTimeout" value="${cpool.checkoutTimeout}"/>
    <property name="initialPoolSize" value="${cpool.minPoolSize}"/>
    <property name="minPoolSize" value="${cpool.minPoolSize}"/>
    <property name="maxPoolSize" value="${cpool.maxPoolSize}"/>
    <property name="maxIdleTime" value="${cpool.maxIdleTime}"/>
    <property name="acquireIncrement" value="${cpool.acquireIncrement}"/>
    <property name="maxIdleTimeExcessConnections" value="${cpool.maxIdleTimeExcessConnections}"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <!-- 去除该动动就不用从jar中加载cmshibernate配置文件了 -->
    <!-- <property name="mappingJarLocations">
        <list>
            <value>/WEB-INF/lib/zqxcom-cms.jar</value>
        </list>
    </property>  -->
    <property name="mappingLocations">
        <list>
            <value>classpath*:/com/jeecms/core/entity/hbm/*.hbm.xml</value>
            <value>classpath*:/com/jeecms/cms/entity/main/hbm/*.hbm.xml</value>
            <value>classpath*:/com/jeecms/cms/entity/assist/hbm/*.hbm.xml</value>
            <value>classpath*:/com/jeecms/dzpt/entity/hbm/Advisory.hbm.xml</value>
            <value>classpath*:/com/jeecms/dzpt/entity/hbm/Apply.hbm.xml</value>
        </list>
    </property>
    <!-- hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect -->
    <property name="hibernateProperties">
        <value>
        hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
        hibernate.show_sql=false
        hibernate.format_sql=false
        hibernate.query.substitutions=true 1, false 0
        hibernate.jdbc.batch_size=20
        hibernate.cache.use_query_cache=true
        </value>
    </property>
    <property name="entityInterceptor">
        <ref local="treeInterceptor"/>
    </property>
    <property name="cacheProvider">
        <ref local="cacheProvider"/>
    </property>
    <property name="lobHandler">
        <ref bean="lobHandler" />
    </property>
</bean>
<bean id="lobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true"/>

<bean id="cacheProvider" class="com.jeecms.common.hibernate3.SpringEhCacheProvider">
    <property name="configLocation">
        <value>classpath:ehcache-hibernate.xml</value>
    </property>
    <property name="diskStoreLocation">
        <value>/WEB-INF/cache/hibernate</value>
    </property>
</bean>
<bean id="treeInterceptor" class="com.jeecms.common.hibernate3.TreeIntercptor"/>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>
<context:annotation-config/>
<tx:annotation-driven transaction-manager="transactionManager" />

解决方案三:

<?xml version="1.0" encoding="UTF-8"?>
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
default-lazy-init="true">

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>/WEB-INF/config/jdbc.properties</value>
        </list>
    </property>
</bean>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
    <property name="driverClass" value="${jdbc.driverClassName}" />
    <property name="jdbcUrl" value="${jdbc.url}" />
    <property name="user" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
    <property name="autoCommitOnClose" value="true"/>
    <property name="checkoutTimeout" value="${cpool.checkoutTimeout}"/>
    <property name="initialPoolSize" value="${cpool.minPoolSize}"/>
    <property name="minPoolSize" value="${cpool.minPoolSize}"/>
    <property name="maxPoolSize" value="${cpool.maxPoolSize}"/>
    <property name="maxIdleTime" value="${cpool.maxIdleTime}"/>
    <property name="acquireIncrement" value="${cpool.acquireIncrement}"/>
    <property name="maxIdleTimeExcessConnections" value="${cpool.maxIdleTimeExcessConnections}"/>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <!-- 去除该动动就不用从jar中加载cmshibernate配置文件了 -->
    <!-- <property name="mappingJarLocations">
        <list>
            <value>/WEB-INF/lib/zqxcom-cms.jar</value>
        </list>
    </property>  -->
    <property name="mappingLocations">
        <list>
            <value>classpath*:/com/jeecms/core/entity/hbm/*.hbm.xml</value>
            <value>classpath*:/com/jeecms/cms/entity/main/hbm/*.hbm.xml</value>
            <value>classpath*:/com/jeecms/cms/entity/assist/hbm/*.hbm.xml</value>
            <value>classpath*:/com/jeecms/dzpt/entity/hbm/Advisory.hbm.xml</value>
            <value>classpath*:/com/jeecms/dzpt/entity/hbm/Apply.hbm.xml</value>
        </list>
    </property>
    <!-- hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect -->
    <property name="hibernateProperties">
        <value>
        hibernate.dialect=org.hibernate.dialect.Oracle9Dialect
        hibernate.show_sql=false
        hibernate.format_sql=false
        hibernate.query.substitutions=true 1, false 0
        hibernate.jdbc.batch_size=20
        hibernate.cache.use_query_cache=true
        </value>
    </property>
    <property name="entityInterceptor">
        <ref local="treeInterceptor"/>
    </property>
    <property name="cacheProvider">
        <ref local="cacheProvider"/>
    </property>
    <property name="lobHandler">
        <ref bean="lobHandler" />
    </property>
</bean>
<bean id="lobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true"/>

<bean id="cacheProvider" class="com.jeecms.common.hibernate3.SpringEhCacheProvider">
    <property name="configLocation">
        <value>classpath:ehcache-hibernate.xml</value>
    </property>
    <property name="diskStoreLocation">
        <value>/WEB-INF/cache/hibernate</value>
    </property>
</bean>
<bean id="treeInterceptor" class="com.jeecms.common.hibernate3.TreeIntercptor"/>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>
<context:annotation-config/>
<tx:annotation-driven transaction-manager="transactionManager" />

解决方案四:

Could not autowire field: private com.jeecms.dzpt.manager.ApplyMng com.jeecms.dzpt.action.ApplyAct.applyMng;
无法注入,是不是大小写没有对应,或者没有注入实体类

解决方案五:

@Autowire默认按照类型装配
@Resource默认按照名称装配,当找不到与名称匹配的bean才会按照类型装配。
错误是找不到匹配的bean,一种出错的原因可能是因为你没有扫描通过注解配置的javabean,或者忘记加注解,Spring容器里没有javabean对象,
如果是配合@Autowire和@Qualifier使用的话,把@Qualifier注解去掉试试。最好把代码贴出来看一下。

时间: 2024-11-08 18:22:18

困扰多时-注解出错,这个框架接触不久,按照前人的配置方式配置后出该问题的相关文章

Spring MVC完全注解方式配置web项目_java

在servlet 3.0 开始web项目可以完全不需要web.xml配置文件了,所以本文的配置只在支持servlet 3.0及以上的web容器中有效 使用的是spring mvc (4.3.2.RELEASE) + thymeleaf(3.0.2.RELEASE), 持久层使用的 spring的 JdbcTemplate, PS:推荐一个很好用的对JdbcTemplate封装的框架:https://github.com/selfly/dexcoder-assistant  . 下面开始具体的配置

java框架spring依赖注入的6种方式

spring中如何给对象的属性复制? 1)通过构造方法2)通过set方法给属性注入值3)p命名空间4)自动转配(了解即可,不推荐使用)5)注解6)通过接口 准备工作(模拟业务方法)Action-->service-->dao 1)UserDao:     p<span style="font-family:Courier New;">ublic class UserDao {           public void save(){              

spring3mvc框架开发中resin和tomcat默认servelt配置处理静态资源

spring3mvc框架开发中resin和tomcat默认servelt配置 解决的问题: 让静态资源不通过DispatcherServlet处理,由容器默认servlet来处理.   在spring3mvc框架开发,web.xml如下配置时     <servlet>         <servlet-name>task</servlet-name>         <servlet-class>org.springframework.web.servle

ios-iOS 播放视频的框架 能直接播放 被转成data数据后的视频吗,而不用写成视频文件去调用播放

问题描述 iOS 播放视频的框架 能直接播放 被转成data数据后的视频吗,而不用写成视频文件去调用播放 iOS 播放视频的框架 能直接播放 被转成data数据后的视频吗,而不用写成视频文件去调用播放 解决方案 写成视频文件是可以调用播放的,写成data也应该可以 解决方案二: 能不能播放跟有没有写成文件是没有关系的,主要是视频流的格式,视频格式是iOS能支持播放的就可以. 解决方案三: 你本来文件的格式是AVFoundation支持的吗? 解决方案四: 是可以的 (instancetype)i

ssh配置时。在xml里配置注入sessionfactory失败。而用@Resource注解的方式配置成功

问题描述 ssh配置时.在xml里配置注入sessionfactory失败.而用@Resource注解的方式配置成功 ssh配置时.在xml里配置注入sessionfactory失败.而用@Resource注解的方式配置sessionfactory却可以成功.这是为什么? <!--配置报错--> public class BaseServiceImpl implements BaseServiceInter { @Resource private SessionFactory sessionF

配置mongodb-c-driver,cmake后编译libbson出错

问题描述 配置mongodb-c-driver,cmake后编译libbson出错 本人学生小白,想配置mongodb-c-driver,在官网上下了mongo-c-driver-1.1.6和cmake,按照教程用cmake先生成libbson的vs工程文件,然后用VS2012编译,结果报错了... 错误如下: 错误 52 error MSB3073: 命令"setlocal "E:Program Files (x86)CMakebincmake.exe" -DBUILD_T

adf g-s2sh框架启动报错,是不是哪没配置好

问题描述 s2sh框架启动报错,是不是哪没配置好 Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.InvalidMappingException: Could not parse mapping docu

Hibernate框架学习之三:深入映射文件的配置

前言 这里主要是对XML版的Hibernate框架的开发进行说明,Annotation版会在另外的文章中在说明.由于Hibernate是一个全方位的ORM框架,那么要实现从Object到Record的完全过渡,实现的桥梁就是这里要讲的映射文件了.映射文件的内容繁多,主要是以开发中会使用到的为主进行说明.大体说来,映射文件主要是对class的映射,还包括属性,属性有分为主键.普通属性与集合属性,甚至还有复合类型等.每种属性都需要进行不同的配置,官方文档看得有点累,所以这里一并做一个总结. 映射文件

云端深度学习框架TensorFlow读取数据IO的高效方式

低效的IO方式 最近通过观察PAI平台上TensoFlow用户的运行情况,发现大家在数据IO这方面还是有比较大的困惑,主要是因为很多同学没有很好的理解本地执行TensorFlow代码和分布式云端执行TensorFlow的区别.本地读取数据是server端直接从client端获得graph进行计算,而云端服务server在获得graph之后还需要将计算下发到各个worker处理(具体原理可以参考视频教程-Tensorflow高级篇:https://tianchi.aliyun.com/compet