Tomcat启动时,卡在了spring创建bean的地方,请问该怎么解决?

项目整合了struts2,spring,hibernate,最近启动项目的时候经常跑
不起来,但有时又可以,可是今晚就老是跑不起来,下面是最后的几行日志,求大神赐教:
十一月 30, 2017 10:35:13 下午 org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
2017-11-30 22:35:13,935 INFO (org.springframework.web.context.ContextLoader:187) - Root WebApplicationContext: initialization started
2017-11-30 22:35:14,208 INFO (org.springframework.web.context.support.XmlWebApplicationContext:456) - Refreshing Root WebApplicationContext: startup date [Thu Nov 30 22:35:14 CST 2017]; root of context hierarchy
2017-11-30 22:35:14,567 INFO (org.springframework.beans.factory.xml.XmlBeanDefinitionReader:315) - Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
2017-11-30 22:35:15,601 INFO (org.springframework.beans.factory.support.DefaultListableBeanFactory:555) - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@5bed0458: defining beans [dataSource,sessionFactory,HibernateConfig,baseDao,loginService,goodService,wsMsgService,LoginAction,WsMsgAction,GoodAction]; root of factory hierarchy
我的spring配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

<!-- <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">   
    <property name="driverClassName">
        <value>com.mysql.jdbc.Driver</value>
    </property>
    <property name="url">
        <value>jdbc:mysql://localhost:3506/xmesdb</value>
    </property>
    <property name="username">
        <value>root</value>
    </property>
    <property name="password">
        <value>123456</value>
    </property>
</bean>
<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource">
        <ref local="dataSource"/>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">
                org.hibernate.dialect.MySQLDialect
            </prop>
            <prop key="hibernate.show_sql">true</prop>
             <prop key="hibernate.hbm2ddl.auto">update</prop>  
             <prop key="hibernate.current_session_context_class">thread</prop>
        </props>
    </property>
    <property name="mappingResources">
        <list>
            <value>com/model/User.hbm.xml</value>
            <value>com/model/WsMsg.hbm.xml</value>
            <value>com/model/GoodMobilePhone.hbm.xml</value>
            <value>com/model/GoodBook.hbm.xml</value>
            <value>com/model/GoodComputer.hbm.xml</value>
            <value>com/model/GoodMobike.hbm.xml</value>
        </list>
    </property>
</bean>
<bean id="HibernateConfig" class="com.hibernate.HibernateConfig">
    <property name="sessionFactory">
        <ref local="sessionFactory"/>
    </property>
</bean>
<bean id="baseDao" class="com.dao.BaseDaoImpl" scope="prototype">
    <property name="sessionFactory">
        <ref local="sessionFactory"/>
    </property>
</bean>
<bean id="loginService" class="com.service.impl.LoginServiceImpl" scope="prototype">
    <property name="baseDao">
        <ref local="baseDao"/>
    </property>
</bean>
<bean id='goodService' class="com.service.impl.GoodServiceImpl" scope="prototype">
    <property name="baseDao">
        <ref local="baseDao"/>
    </property>
</bean>
<bean id="wsMsgService" class="com.webSocket.Service.impl.WsMsgServiceImpl" scope="prototype">
</bean>
<bean id="LoginAction" class="com.action.LoginAction" scope="prototype">
    <property name="baseDao" ref="baseDao"></property>
    <property name="loginService" ref="loginService"></property>
    <property name="wsMsgService" ref="wsMsgService"></property>
</bean> 
<bean id="WsMsgAction" class="com.action.WsMsgAction" scope="prototype">
    <property name="wsMsgService" ref="wsMsgService"></property>    
</bean> 
<bean id="GoodAction" class="com.action.GoodAction" scope="prototype">
    <property name="goodService" ref="goodService"></property>    

</bean>


菜鸟一枚,求教求教

2个回答

信息太少,日志换成debug,找找关键位置的提示,或许有报错或者警告。贴出来的配置没看到什么问题,也许是其他配置文件没有加载到或者错误导致的。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Python+OpenCV计算机视觉

Python+OpenCV计算机视觉

Spring里如何使一个单例类在tomcat启动时初始化

Spring里如何使一个单例类在tomcat启动时初始化? 比如 类是: com.common.cache.BusinessCache 注入的DAO是 : com.common.cache.BusinessDAO 目前问题是,debug时,发现BusinessCache里得到的dao是null的。 求解。。应该怎么做?

关于tomcat启动spring注入的时候报找到2个bean

我确定在自己的类中Service只有一个实现..但是bean不唯一的错..我现在也很迷茫..用的开发工具是IDEA 求教各位大神 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'baseInfoController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.ljljob.p2p.core.base.service.ISystemDictionaryItemService com.ljljob.p2p.website.controller.BaseInfoController.systemDictionaryItemService; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [com.ljljob.p2p.core.base.service.ISystemDictionaryItemService] is defined: expected single matching bean but found 2: systemDictionaryItemServiceImpl,ISystemDictionaryItemService spring配置如下 <!--1:配置注解解析--> <context:annotation-config/> <context:component-scan base-package="com.ljljob.p2p"/> <!--2:加载外部资源--> <context:property-placeholder location="classpath:db.properties,classpath:sms.properties,classpath:email.properties"/> <!--3:配置dataSource--> <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"> <property name="driverClassName" value="${jdbc.driverClassName}"/> <property name="url" value="${jdbc.url}"/> <property name="username" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/> </bean> <!--4:配置sesssionFactory--> <bean id="sqlsessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="configLocation" value="classpath:mybatis.cfg.xml"/> <property name="mapperLocations" value="classpath:com/ljljob/p2p/*/*/mapper/*Mapper.xml"/> <property name="typeAliasesPackage" value="com.ljljob.p2p"/> </bean> <!--5:配置事务管理器--> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"/> </bean> <!--6:配置事务处理--> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="query*" read-only="true" propagation="SUPPORTS"/> <tx:method name="select*" read-only="true" propagation="SUPPORTS"/> <tx:method name="get*" read-only="true" propagation="SUPPORTS"/> <tx:method name="list*" read-only="true" propagation="SUPPORTS"/> <tx:method name="*" propagation="REQUIRED"/> </tx:attributes> </tx:advice> <!--7:配置AOP--> <aop:config> <aop:pointcut id="txPointCut" expression="execution(* com.ljljob.p2p..service.*.*(..))"/> <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointCut"/> </aop:config> <!--配置mapper扫描器--> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.ljljob.p2p.core"/> </bean> </beans>

如何在spring启动时(不是项目启动完成后),在初始化执行某一个bean的init-method中添加自己的日志到系统日志中?

spring项目启动时,初始化某一个bean,并设置了init-method,如何在这个init-method中添加自己的日志到系统启动日志中?用Logger LOGGER = LoggerFactory.getLogger(),debug提示Logger cannot be resolved to a variable。注意不是项目启动完成后的打印日志,是在启动的过程中,初始化时执行这个方法的时候打印出我写的日志。

服务器启动后,发现无法创建bean,类确定存在,配置文件也没有问题,请问是什么原因造成这个异常

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testAction' defined in ServletContext resource [/WEB-INF/applicationContext-test.xml]: Cannot resolve reference to bean 'tencentMusicAction' while setting bean property 'tencentMusicAction'; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.demo.web.action.TencentMusicAction] for bean with name 'tencentMusicAction' defined in ServletContext resource [/WEB-INF/applicationContext-test.xml]; nested exception is java.lang.ClassNotFoundException: com.demo.web.action.TencentMusicAction ValueResolver.resolveReference(BeanDefinitionValueResolver.java:275) Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.demo.web.action.TencentMusicAction] for bean with name 'tencentMusicAction' defined in ServletContext resource [/WEB-INF/applicationContext-test.xml]; nested exception is java.lang.ClassNotFoundException: com.demo.web.action.TencentMusicAction at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1138) at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1102) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:386) at java.security.AccessController.doPrivileged(Native Method) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269) ... 42 more Caused by: java.lang.ClassNotFoundException: com.demo.web.action.TencentMusicAction at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526) at org.springframework.util.ClassUtils.forName(ClassUtils.java:242) at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:383) at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1135) ... 52 more

quartz和spring整合后tomcat启动后如何去掉第一次执行?使其能在定时时间执行

<bean name="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" > <property name="triggers"> <list> <ref bean="cronTrigger"/> <ref bean="cronTrigger1"/> <ref bean="cronTrigger2"/> </list> </property> <property name="applicationContextSchedulerContextKey" value="applicationContextKey"/> <property name="configLocation" value="classpath:quartz.properties"/> <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"> <property name="jobDetail" ref="helloWorldJob"/> <property name="cronExpression" value="0 0/2 8-21 *,* * ?"/> </bean> 每次启动tomcat后调度任务都会立即执行一次,然后到定时时间再执行一次,怎样才能不让tomcat启动后立即执行,而是在定时的时间执行一次??

spring容器中bean不在同一个文件下的引用问题

一般情况下我们将bean定义在不同xml中,但是他们的文件名有着命名规则,例如: applicationContext-aaa.xml,这样我们就可以在web.xml文件中使用applicationContext-*.xml 来实现不同文件下的bean之间的相互引用,网上搜了搜说是他们最后会被整理成一个xml文件 那么我现在遇到的问题是:有一部分bean是在tailorbird-spring-hibernatedb.xml,在 web容器中申明过了,但是在Tomcat启动的时候applicationContext-aaa.xml中的bean 却不能引入tailorbird-spring-hibernatedb.xml中声明的bean,不知道是否是因为他们 的命名有问题的原因,希望得到大家的帮助,到底是怎么回事。。。

spring初始化bean的问题

如题, 工作中遇到一个类似"循环引用"的问题: ``` <bean id="A" class="com.xxx.A" init-method="initA"> <property name="B" ref="B"></property> </bean> <bean id="B" class="com.xxx.B" init-method="initB"> </bean> ``` 上面的xml加载初始化 "A" bean的时候, 配置ref B 会依据无参构造器创建“B”Bean, 并暴露一个exposedObj提前返回, 此时initB未执行 , 继续完成"A" bean 的创建, 执行initA , 而initA需要initB提供的一些变量, 就会发生空指针异常. 解决方法一: 先初始化B bean, 还有其他方法吗?

Sring mvc +mybatis部署tomcat导致tomcat启动假死

mybatis如果出现如下错误![图片说明](https://img-ask.csdn.net/upload/201506/01/1433123778_266118.png)会导致tomcat假死并且等待很长时间才报错,错误信息不准确,导致tomcat栈溢出,修改了tomcat内存参数之后,错误原因可以看出来,但是tomcat终端一直报错,停不下来,求解 <description>Spring公共配置 </description> <!-- 使用annotation 自动注册bean, 并保证@Required、@Autowired的属性被注入 --> <context:component-scan base-package="com.hukan.hkhx"> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" /> <context:exclude-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice" /> </context:component-scan> <!-- MyBatis配置 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!-- 自动扫描entity目录, 省掉Configuration.xml里的手工配置 --> <property name="typeAliasesPackage" value="com.hukan.hkhx.entity" /> <!-- 显式指定Mapper文件位置 --> <property name="mapperLocations" value="classpath:/mybatis/*/*Mapper.xml" /> </bean> <!-- 扫描basePackage下所有以@MyBatisRepository标识的 接口 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.hukan.hkhx.repository.*" /> <property name="annotationClass" value="com.base.common.MyBatisRepository" /> </bean> <!-- 另一个事务管理器, Jdbc单数据源事务 --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> <!-- 使用annotation定义事务 --> <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" /> <!-- JSR303 Validator定义 --> <!-- <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" /> --> <!-- production环境 --> <beans profile="production"> <context:property-placeholder ignore-unresolvable="true" location="classpath*:/application.properties" /> <!-- 数据源配置, 使用Tomcat JDBC连接池 --> <bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource" destroy-method="close"> <!-- Connection Info --> <property name="driverClassName" value="${jdbc.driver}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <!-- Connection Pooling Info --> <property name="maxActive" value="${jdbc.pool.maxActive}" /> <property name="maxIdle" value="${jdbc.pool.maxIdle}" /> <property name="minIdle" value="0" /> <property name="defaultAutoCommit" value="false" /> </bean>

spring中的bean何时被实例化的

今天在读spring技术内幕的时候,里面有一句话,在容器初始化完成以后,IoC容器的使用就准备好了,在客户第一次向IoC容器请求Bean时,IoC容器对相关的Bean依赖关系进行注入。当我deBug项目的时候,发现TOMCAT启动的阶段,就开始调用相关配置Bean的构造方法实例化,我想知道bean到底是在那个阶段实例化?

SSH整合,启动tomcat报错找不到Spring的配置文件

十月 28, 2016 8:11:34 上午 org.apache.catalina.core.AprLifecycleListener init 信息: Loaded APR based Apache Tomcat Native library 1.1.29 using APR version 1.4.8. 十月 28, 2016 8:11:34 上午 org.apache.catalina.core.AprLifecycleListener init 信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true]. 十月 28, 2016 8:11:36 上午 org.apache.catalina.core.AprLifecycleListener initializeSSL 信息: OpenSSL successfully initialized (OpenSSL 1.0.1e 11 Feb 2013) 十月 28, 2016 8:11:36 上午 org.apache.coyote.AbstractProtocol init 信息: Initializing ProtocolHandler ["http-apr-8080"] 十月 28, 2016 8:11:36 上午 org.apache.coyote.AbstractProtocol init 信息: Initializing ProtocolHandler ["ajp-apr-8009"] 十月 28, 2016 8:11:36 上午 org.apache.catalina.startup.Catalina load 信息: Initialization processed in 2856 ms 十月 28, 2016 8:11:36 上午 org.apache.catalina.core.StandardService startInternal 信息: Starting service Catalina 十月 28, 2016 8:11:36 上午 org.apache.catalina.core.StandardEngine startInternal 信息: Starting Servlet Engine: Apache Tomcat/7.0.52 十月 28, 2016 8:11:36 上午 org.apache.catalina.startup.HostConfig deployDirectory 信息: Deploying web application directory H:\tomcat\apache-tomcat-7.0.52\webapps\gh 十月 28, 2016 8:11:53 上午 org.apache.catalina.core.ApplicationContext log _信息: No Spring WebApplicationInitializer types detected on classpath_ 十月 28, 2016 8:11:55 上午 org.apache.catalina.core.ApplicationContext log 信息: Initializing Spring root WebApplicationContext 十月 28, 2016 8:12:03 上午 com.mchange.v2.log.MLog <clinit> 信息: MLog clients using java 1.4+ standard logging. 十月 28, 2016 8:12:04 上午 com.mchange.v2.c3p0.C3P0Registry banner 信息: Initializing c3p0-0.9.2.1 [built 20-March-2013 10:47:27 +0000; debug? true; trace: 10] 十月 28, 2016 8:12:12 上午 com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager 信息: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1bqp7459k2e709gh0u9tz|3cd2eb, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1bqp7459k2e709gh0u9tz|3cd2eb, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:mysql:///registersys?characterEncoding=utf-8, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 3, numHelperThreads -> 3, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ] 2016-10-28 08:12:20,005 WARN [localhost-startStop-1] support.AbstractApplicationContext (AbstractApplicationContext.java:544) - Exception encountered during context initialization - cancelling refresh attempt org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: Could not get constructor for org.hibernate.persister.entity.SingleTableEntityPersister____

spring security4在tomcat7下起动卡住了,什么情况,求指点!

准备学习下Spring Security 4,整合spring mvc时正常,加入spring security包后也下常,但是把Spring Security配置文件加入到web.xml启动配置后就有问题了。 spring-4.1.6.RELEASE spring-security-4.0.1.RELEASE tomcat-7.0.28 Ideal 14 整个启动过程如以下及1,2楼回复所示,启动到初始化bean之后就不动了。也不报错,不知道这是什么情况造成的 启动日志: ``` D:\programs\container\tomcat-7.0.28-eclipse\bin\catalina.bat run [2015-04-30 10:58:34,456] Artifact security-war:war exploded: Server is not connected. Deploy is not available. Using CATALINA_BASE: "C:\Users\Administrator\.IntelliJIdea14\system\tomcat\Unnamed_study-spsecurity_2" Using CATALINA_HOME: "D:\programs\container\tomcat-7.0.28-eclipse" Using CATALINA_TMPDIR: "D:\programs\container\tomcat-7.0.28-eclipse\temp" Using JRE_HOME: "C:\Program Files\Java\jdk1.7.0_71" Using CLASSPATH: "D:\programs\container\tomcat-7.0.28-eclipse\bin\bootstrap.jar;D:\programs\container\tomcat-7.0.28-eclipse\bin\tomcat-juli.jar" 四月 30, 2015 10:58:35 下午 org.apache.catalina.core.AprLifecycleListener init 信息: Loaded APR based Apache Tomcat Native library 1.1.24 using APR version 1.4.6. 四月 30, 2015 10:58:35 下午 org.apache.catalina.core.AprLifecycleListener init 信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true]. 四月 30, 2015 10:58:36 下午 org.apache.catalina.core.AprLifecycleListener initializeSSL 信息: OpenSSL successfully initialized (OpenSSL 1.0.1c 10 May 2012) 四月 30, 2015 10:58:36 下午 org.apache.coyote.AbstractProtocol init 信息: Initializing ProtocolHandler ["http-apr-8080"] 四月 30, 2015 10:58:36 下午 org.apache.coyote.AbstractProtocol init 信息: Initializing ProtocolHandler ["ajp-apr-8009"] 四月 30, 2015 10:58:36 下午 org.apache.catalina.startup.Catalina load 信息: Initialization processed in 1466 ms 四月 30, 2015 10:58:36 下午 org.apache.catalina.core.StandardService startInternal 信息: Starting service Catalina 四月 30, 2015 10:58:36 下午 org.apache.catalina.core.StandardEngine startInternal 信息: Starting Servlet Engine: Apache Tomcat/7.0.28 四月 30, 2015 10:58:36 下午 org.apache.coyote.AbstractProtocol start 信息: Starting ProtocolHandler ["http-apr-8080"] 四月 30, 2015 10:58:36 下午 org.apache.coyote.AbstractProtocol start 信息: Starting ProtocolHandler ["ajp-apr-8009"] 四月 30, 2015 10:58:36 下午 org.apache.catalina.startup.Catalina start 信息: Server startup in 59 ms [2015-04-30 10:58:37,115] Artifact security-war:war exploded: Artifact is being deployed, please wait... Connected to server ```

spring+quartz做的定时任务,tomcat启动没问题,就是定时任务不执行,是什么原因?

1.applicationContext_quartz.xml内容 ``` <?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: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.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd"> <!-- Spring定时任务 --> <!-- 定时任务 --> <bean id="quartzAction" class="com.test.action.QuartzTaskAction"/> <!-- 第一步:指定执行的类的方法名 --> <bean id="xhhf_jd" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject"><ref bean="quartzAction"/></property> <property name="targetMethod"><value>xhhfDates</value></property> </bean> <!-- 第二步:指定触发的类型 --> <bean id="xhhf_ct" class="org.springframework.scheduling.quartz.CronTriggerBean"> <property name="jobDetail"><ref bean="xhhf_jd" /></property> <property name="cronExpression" value="0/2 * * * * ?" /> </bean> <!-- 第三步:开启定时任务 --> <bean id="startQuertz" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref bean="xhhf_ct"/> </list> </property> </bean> </beans> ``` 2.QuartzTaskAction.action内容 ``` package com.test.action; public class QuartzTaskAction{ public void xhhfDates(){ System.out.println("看我执行中。。。。"); } } ``` 3web.xml配置内容 ``` <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/config/applicationContext_*.xml </param-value> </context-param> ``` 4.tomcat启动日志 ``` 2015-3-14 10:21:11 org.apache.catalina.core.AprLifecycleListener init 信息: Loaded APR based Apache Tomcat Native library 1.1.30 using APR version 1.4.8. 2015-3-14 10:21:11 org.apache.catalina.core.AprLifecycleListener init 信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true]. 2015-3-14 10:21:12 org.apache.catalina.core.AprLifecycleListener initializeSSL 信息: OpenSSL successfully initialized (OpenSSL 1.0.1g 7 Apr 2014) 2015-3-14 10:21:12 org.apache.coyote.AbstractProtocol init 信息: Initializing ProtocolHandler ["http-apr-80"] 2015-3-14 10:21:12 org.apache.coyote.AbstractProtocol init 信息: Initializing ProtocolHandler ["ajp-apr-8009"] 2015-3-14 10:21:12 org.apache.catalina.startup.Catalina load 信息: Initialization processed in 1196 ms 2015-3-14 10:21:12 org.apache.catalina.core.StandardService startInternal 信息: Starting service Catalina 2015-3-14 10:21:12 org.apache.catalina.core.StandardEngine startInternal 信息: Starting Servlet Engine: Apache Tomcat/7.0.54 2015-3-14 10:21:19 org.apache.tomcat.websocket.server.WsSci onStartup 信息: JSR 356 WebSocket (Java WebSocket 1.0) support is not available when running on Java 6. To suppress this message, run Tomcat on Java 7, remove the WebSocket JARs from $CATALINA_HOME/lib or add the WebSocket JARs to the tomcat.util.scan.DefaultJarScanner.jarsToSkip property in $CATALINA_BASE/conf/catalina.properties. Note that the deprecated Tomcat 7 WebSocket API will be available. 2015-3-14 10:21:19 org.apache.catalina.core.ApplicationContext log 信息: Set web app root system property: 'Heli' = [D:\Tomcat\webapps\Heli\] 2015-3-14 10:21:19 org.apache.catalina.core.ApplicationContext log 信息: Initializing log4j from [D:\Tomcat\webapps\Heli\WEB-INF\log4j.properties] 2015-3-14 10:21:19 org.apache.catalina.core.ApplicationContext log 信息: Initializing Spring root WebApplicationContext servlet初始化。。。。 2015-3-14 10:21:29 com.sun.faces.config.ConfigureListener contextInitialized 信息: 初始化上下文 '' 的 Mojarra 2.0.3 (FCS b03) 2015-3-14 10:21:30 com.sun.faces.spi.InjectionProviderFactory createInstance 信息: JSF1048:有 PostConstruct/PreDestroy 注释。标有这些注释的 ManagedBeans 方法将表示注释已处理。 2015-3-14 10:21:33 org.apache.coyote.AbstractProtocol start 信息: Starting ProtocolHandler ["http-apr-80"] 2015-3-14 10:21:33 org.apache.coyote.AbstractProtocol start 信息: Starting ProtocolHandler ["ajp-apr-8009"] 2015-3-14 10:21:33 org.apache.catalina.startup.Catalina start 信息: Server startup in 21100 ms ``` 以上是全部内容,请问各位大神问题出在哪里了?急死了

tomcat容器与spring容器的关系?

请问tomcat容器与spring容器是父子关系吗,tomcat容器包含spring容器?

请问大家spring能够不依赖于容器(如tomcat)运行吗?

我正在做一个JMS消息处理服务,监听JMS消息并进行处理。想利用spring整合的jms模版和定时调度等功能实现,现在正在思考的问题就是:这个JMS消息处理服务本身是可以与tomcat之类的容器无关的,我想做成一个可以启动的服务(比如通过java命令:java startService 启动),请问spring能够不依赖于容器(如tomcat)运行吗? [b]问题补充:[/b] 如果可以,请问spring的初始化该如何做呢? [b]问题补充:[/b] 谢谢,我试一下先:) [b]问题补充:[/b] 我举个例子:有一个JMS监听器,程序一启动JMS监听器就马上启动监听JMS消息 <code> <!-- this is the attendant message listener container --> <bean id="listenerContainer" class="org.springframework.jms.listener.SimpleMessageListenerContainer102"> <property name="concurrentConsumers" value="1" /> <property name="connectionFactory" ref="jmsQueueConnectionFactory" /> <property name="destination" ref="receiveDestination" /> <property name="messageListener" ref="resourceMessageListener" /> <property name="sessionTransacted" value="true"/> </bean> </code> 请问如何作为一个独立的服务启动呢? [b]问题补充:[/b] 谢谢各位,的确是 new ClassPathXmlApplicationContext("spring.xml"); 这样一句就可以完成所有的初始化。 可惜分数只能给一个人,我只能给了正面回答我的第一个人。 很感谢大家的帮助!

Spring容器是在什么时候创建完成的?

Spring的容器是在什么时候启动的,用ApplicationContext手动加载和在web.xml中 配置<context-param>和<listener>有什么区别,还有bean是在什么时候生成的, 是在spring容器创建完成的时候就生成了还是在需要用的时候才会生成

spring使用事务注解后启动tomcat报错

严重: StandardWrapper.Throwable org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'tagController': Unsatisfied dependency expressed through field 'tagService'; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'tagServiceImpl' is expected to be of type 'com.etag.facesense.service.impl.TagServiceImpl' but was actually of type 'com.sun.proxy.$Proxy26' at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:171) at javax.servlet.GenericServlet.init(GenericServlet.java:158) at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1188) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1132) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1021) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5069) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1410) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1400) 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.BeanNotOfRequiredTypeException: Bean named 'tagServiceImpl' is expected to be of type 'com.etag.facesense.service.impl.TagServiceImpl' but was actually of type 'com.sun.proxy.$Proxy26' at org.springframework.beans.factory.support.DefaultListableBeanFactory.checkBeanNotOfRequiredType(DefaultListableBeanFactory.java:1510) at org.springframework.beans.factory.support.DefaultListableBeanFactory.checkBeanNotOfRequiredType(DefaultListableBeanFactory.java:1517) at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1489) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585) ... 31 more 六月 19, 2018 8:50:56 下午 org.apache.catalina.core.StandardContext loadOnStartup 严重: Servlet [dispatcher] in web application [/facesense] threw load() exception org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'tagServiceImpl' is expected to be of type 'com.etag.facesense.service.impl.TagServiceImpl' but was actually of type 'com.sun.proxy.$Proxy26' at org.springframework.beans.factory.support.DefaultListableBeanFactory.checkBeanNotOfRequiredType(DefaultListableBeanFactory.java:1510) at org.springframework.beans.factory.support.DefaultListableBeanFactory.checkBeanNotOfRequiredType(DefaultListableBeanFactory.java:1517) at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1489) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1104) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:585) at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:366) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543) at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:668) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:634) at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:682) at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:553) at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:494) at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:171) at javax.servlet.GenericServlet.init(GenericServlet.java:158) at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1188) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1132) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1021) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5069) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1410) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1400) 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)

Spring注入Bean出现空指针异常

``` @Bean public ServletRegistrationBean ActionServlet() { ServletRegistrationBean registration = new ServletRegistrationBean(); registration.setName("ActionServlet"); registration.setOrder(1); registration.addUrlMappings("*.do"); registration.setServlet(new ActionServlet()); registration.addInitParameter("config", "/WEB-INF/conf/action_config.xml"); registration.addInitParameter("ignoreCase", "N"); registration.setLoadOnStartup(1); return registration; } ``` ``` java.lang.NullPointerException: null at org.dom4j.io.SAXReader.read(SAXReader.java:284) at com.yuangou.ecp.bp.web.controller.ActionMappingsParse.parse(ActionMappingsParse.java:34) at com.yuangou.ecp.bp.web.controller.servlet.ActionServlet.init(ActionServlet.java:502) at javax.servlet.GenericServlet.init(GenericServlet.java:158) at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1144) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:986) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4978) at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedContext.deferredLoadOnStartup(TomcatEmbeddedContext.java:78) at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.performDeferredLoadOnStartup(TomcatEmbeddedServletContainer.java:288) at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.start(TomcatEmbeddedServletContainer.java:211) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.startEmbeddedServletContainer(EmbeddedWebApplicationContext.java:297) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:145) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:546) at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:360) at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134) at com.murong.ecp.bp.common.util.ECPApplication.run(ECPApplication.java:30) at com.murong.ecp.netpay.jnefss.web.SpringBootApplication.main(SpringBootApplication.java:18) ```

sqlSessionTemplate在tomcat启动时自动关闭

sqlSessionTemplate在tomcat启动时自动关闭 数据库连接没有问题 <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="configLocation" value="/WEB-INF/classes/resources/mybatis/mybatis-config.xml"></property> <!-- mapper扫描 --> <property name="mapperLocations" value="/WEB-INF/classes/resources/mybatis/*/*.xml"></property> </bean> <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate"> <constructor-arg ref="sqlSessionFactory" /> <!-- <constructor-arg index="1" value="BATCH" /> --> </bean>

spring实例化bean问题

是这样的,写了一个小项目,用的spring,获取bean的方式是用工厂类的方式, 具体代码是这样 IInterceptor interceptor = (IInterceptor)BeanFactory.getInstance("interceptorRedirect"); 工厂类里面是这样写的 ![图片说明](https://img-ask.csdn.net/upload/201704/25/1493087827_172358.png) 这样写完全没问题的,但是我就发现,每次在获取一个类的时候 都要把整个applicationContext.xml注入一遍,,但是我就需要里面的数据源和我要的一个类,里面配的很多其他的都不需要,我就在想有没有其他方法或者技术,只实例化我需要的,这样速度肯定会快一点吧,还望大神指点一下。

2019 Python开发者日-培训

2019 Python开发者日-培训

150讲轻松搞定Python网络爬虫

150讲轻松搞定Python网络爬虫

设计模式(JAVA语言实现)--20种设计模式附带源码

设计模式(JAVA语言实现)--20种设计模式附带源码

YOLOv3目标检测实战:训练自己的数据集

YOLOv3目标检测实战:训练自己的数据集

java后台+微信小程序 实现完整的点餐系统

java后台+微信小程序 实现完整的点餐系统

三个项目玩转深度学习(附1G源码)

三个项目玩转深度学习(附1G源码)

初级玩转Linux+Ubuntu(嵌入式开发基础课程)

初级玩转Linux+Ubuntu(嵌入式开发基础课程)

2019 AI开发者大会

2019 AI开发者大会

玩转Linux:常用命令实例指南

玩转Linux:常用命令实例指南

一学即懂的计算机视觉(第一季)

一学即懂的计算机视觉(第一季)

4小时玩转微信小程序——基础入门与微信支付实战

4小时玩转微信小程序——基础入门与微信支付实战

Git 实用技巧

Git 实用技巧

Python数据清洗实战入门

Python数据清洗实战入门

使用TensorFlow+keras快速构建图像分类模型

使用TensorFlow+keras快速构建图像分类模型

实用主义学Python(小白也容易上手的Python实用案例)

实用主义学Python(小白也容易上手的Python实用案例)

程序员的算法通关课:知己知彼(第一季)

程序员的算法通关课:知己知彼(第一季)

MySQL数据库从入门到实战应用

MySQL数据库从入门到实战应用

机器学习初学者必会的案例精讲

机器学习初学者必会的案例精讲

手把手实现Java图书管理系统(附源码)

手把手实现Java图书管理系统(附源码)

极简JAVA学习营第四期(报名以后加助教微信:eduxy-1)

极简JAVA学习营第四期(报名以后加助教微信:eduxy-1)

.net core快速开发框架

.net core快速开发框架

玩转Python-Python3基础入门

玩转Python-Python3基础入门

Python数据挖掘简易入门

Python数据挖掘简易入门

微信公众平台开发入门

微信公众平台开发入门

程序员的兼职技能课

程序员的兼职技能课

Windows版YOLOv4目标检测实战:训练自己的数据集

Windows版YOLOv4目标检测实战:训练自己的数据集

HoloLens2开发入门教程

HoloLens2开发入门教程

微信小程序开发实战

微信小程序开发实战

Java8零基础入门视频教程

Java8零基础入门视频教程

相关热词 c# 开发接口 c# 中方法上面的限制 c# java 时间戳 c#单元测试入门 c# 数组转化成文本 c#实体类主外键关系设置 c# 子函数 局部 c#窗口位置设置 c# list 查询 c# 事件 执行顺序
立即提问
相关内容推荐