81,092
社区成员
发帖
与我相关
我的任务
分享
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clearDataImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: public com.jiezisoft.opermanager.service.ServerStatusInfoService com.jiezisoft.opermanager.service.impl.ClearDataImpl.serverStatusInfoService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.jiezisoft.opermanager.service.ServerStatusInfoService] 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:289)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1146)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:296)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:628)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5077)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5591)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:677)
at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1939)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: public com.jiezisoft.opermanager.service.ServerStatusInfoService com.jiezisoft.opermanager.service.impl.ClearDataImpl.serverStatusInfoService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.jiezisoft.opermanager.service.ServerStatusInfoService] 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$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:517)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)
... 26 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.jiezisoft.opermanager.service.ServerStatusInfoService] 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.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:988)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:858)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:770)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:489)
... 28 more
八月 07, 2017 8:19:49 下午 org.apache.catalina.core.StandardContext startInternal
@Transactional
@Service(value = "clearDataImpl")
public class ClearDataImpl
{
private static final Log log = LogFactory.getLog(ClearDataImpl.class);
@Autowired
public ServerStatusInfoService serverStatusInfoService;
@Autowired
public ServiceStatusInfoHisService serviceStatusInfoHisService;
//清理5天前的服务器状态信息
public void clearServerStatusData(String updateTime)
{
serverStatusInfoService.clearDataInTime(updateTime);
}
public void clearServerStatusData()
{
log.debug("==========定时执行1=======");
serverStatusInfoService.clearDataInTime(null);
}
public void clearServiceStatusInfoHisData(String updateTime)
{
serviceStatusInfoHisService.clearDataInTime(updateTime);
}
public void clearServiceStatusInfoHisData()
{
log.debug("==========定时执行2=======");
serviceStatusInfoHisService.clearDataInTime(null);
}
}
<task:annotation-driven/>
<bean id="clearDataImpl1" class="com.jiezisoft.opermanager.service.impl.ClearDataImpl"></bean>
<task:scheduled-tasks>
<task:scheduled ref="clearDataImpl" method="clearServerStatusData" cron="0/30 * * * * ?"/><!-- 每天0点执行 -->
<task:scheduled ref="clearDataImpl" method="clearServiceStatusInfoHisData" cron="0/30 * * * * ?"/><!-- 每天0点执行 -->
<!-- <task:scheduled ref="BatDealServiceImpl" method="batDealTask" cron="0/30 * * * * ? "/> --><!-- 30秒执行1次 -->
<!-- <task:scheduled ref="BatDealServiceImpl" method="batDealTask" cron="0 0,30 * * * ? "/> --><!-- 半小时执行一次,00分,30分 -->
</task:scheduled-tasks>
package com.xxxx.opermanager.service.impl;
import java.util.Date;
import javax.annotation.Resource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.xxxx.opermanager.common.util.DateUtil;
import com.xxxx.opermanager.common.util.PropertyPlaceholder;
import com.xxxx.opermanager.dao.ServerStatusInfoDao;
import com.xxxx.opermanager.dao.ServiceStatusInfoHisDao;
import com.xxxx.opermanager.service.ServerStatusInfoService;
import com.xxxx.opermanager.service.ServiceStatusInfoHisService;
/***
*
* @ClassName: ClearDataImpl
* @Description: 清理数据
* @author yinjh
* @date 2016-10-9 下午4:53:53
* @version 1.0
*/
@Transactional
@Service(value = "clearDataImpl")
public class ClearDataImpl implements ClearData
{
private static final Log log = LogFactory.getLog(ClearDataImpl.class);
@Autowired
private ServerStatusInfoDao serverStatusInfoDao;
@Autowired
private ServiceStatusInfoHisDao serviceStatusInfoHisDao;
@Override
public void clearServerStatusData()
{
log.debug("==========定时清理服务器状态=======执行时间:"+DateUtil.date2String(new Date()));
int date = Integer.parseInt(PropertyPlaceholder.getProperty("clear_data"));
String updateTime = DateUtil.date2String(DateUtil.addDays(new Date(), date * -1));
serverStatusInfoDao.clearDataInTime(updateTime);
}
@Override
public void clearServiceStatusInfoHisData()
{
log.debug("==========定时清理服务状态=======执行时间"+DateUtil.date2String(new Date()));
int date = Integer.parseInt(PropertyPlaceholder.getProperty("clear_data"));
String updateTime = DateUtil.date2String(DateUtil.addDays(new Date(), date * -1));
serviceStatusInfoHisDao.clearDataInTime(updateTime);
}
}
package com.jiezisoft.opermanager.service.impl;
import 省略~~~~
@Service//(value = "serverStatusInfoService")
public class ServerStatusInfoServiceImpl implements ServerStatusInfoService {
-----方法省略
}
springMVC的配置
<?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:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd ">
<context:annotation-config/>
<context:component-scan base-package="com.jiezisoft.opermanager">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
</context:component-scan>
<!-- 对静态资源文件的访问 -->
<mvc:resources mapping="/static/**" location="/static/"/>
<!-- 对静态资源文件的访问, 将无法mapping到Controller的path交给default servlet handler处理 -->
<mvc:default-servlet-handler/>
<!-- <aop:aspectj-autoproxy proxy-target-class="true"/> -->
<aop:aspectj-autoproxy />
<mvc:annotation-driven validator="validator">
<mvc:message-converters register-defaults="true">
<bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter"/>
<bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes" value = "text/plain;charset=UTF-8" />
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 配置jsp路径的前缀 -->
<property name="prefix" value="/WEB-INF/jsp/" />
<!-- 配置jsp路径的后缀 -->
<property name="suffix" value=".jsp" />
</bean>
<!-- 加载properties文件配置信息 -->
<bean id="propertyPlaceholder" scope="singleton" class="com.jiezisoft.opermanager.common.util.PropertyPlaceholder">
<property name="locations">
<list>
<value>classpath:application.properties</value>
</list>
</property>
</bean>
<!-- 校验器 -->
<bean id="validator"
class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<!-- hibernate校验器-->
<property name="providerClass" value="org.hibernate.validator.HibernateValidator" />
<!-- 指定校验使用的资源文件,在文件中配置校验错误信息,如果不指定则默认使用classpath下的ValidationMessages.properties -->
<property name="validationMessageSource" ref="messageSource" />
</bean>
<!-- 校验错误信息配置文件 -->
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<!-- 资源文件名-->
<property name="basenames">
<list>
<value>classpath:validator/*</value>
</list>
</property>
<!-- 资源文件编码格式 -->
<property name="fileEncodings" value="utf-8" />
<!-- 对资源文件内容缓存时间,单位秒 -->
<property name="cacheSeconds" value="120" />
</bean>
<!-- SpringMVC上传文件时,需要配置MultipartResolver处理器 -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="defaultEncoding" value="UTF-8"/>
<!-- 指定所上传文件的总大小不能超过5000KB。注意maxUploadSize属性的限制不是针对单个文件,而是所有文件的容量之和 -->
<property name="maxUploadSize" value="100000000"/>
</bean>
<!-- SpringMVC在超出上传文件限制时,会抛出org.springframework.web.multipart.MaxUploadSizeExceededException -->
<!-- 该异常是SpringMVC在检查上传的文件信息时抛出来的,而且此时还没有进入到Controller方法中 -->
<bean id="exceptionResolver" class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<!-- 遇到MaxUploadSizeExceededException异常时,自动跳转到/WEB-INF/jsp/error_fileupload.jsp页面 -->
<prop key="org.springframework.web.multipart.MaxUploadSizeExceededException">error/error_fileupload</prop>
</props>
</property>
</bean>
<!-- 全局异常处理器 -->
<bean class="com.jiezisoft.opermanager.exception.CustomExceptionResolver"></bean>
</beans>