问题描述
web.xml 配置如下<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name></display-name> <!-- log4配置 --> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>/WEB-INF/classes/log4j.properties</param-value> </context-param> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener><!-- 字符编码过滤器 --><filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 载入spring --><context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/classes/applicationContext.xml</param-value> <!--可载入多个配置文件分隔符 , ; t n --> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list></web-app>主配置如下:<?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:context="http://www.springframework.org/schema/context"xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName"> <value>com.mysql.jdbc.Driver</value> </property> <property name="url"> <value>jdbc:mysql://192.168.1.222:3306/aaa</value> </property> <property name="username"> <value>root</value> </property> <property name="password"> <value>nws</value> </property> </bean> <!-- 配置事务管理器 --><bean id="transcationManager"class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource" /></bean><tx:advice id="txAdvice" transaction-manager="transcationManager"><tx:attributes><tx:method name="insert*" propagation="REQUIRED" /><tx:method name="del*" propagation="REQUIRED" /><tx:method name="update*" propagation="REQUIRED" /><tx:method name="*" read-only="true" /></tx:attributes></tx:advice><!-- 配置AOP切入点 --><aop:config><aop:pointcut id="allManagerMethod"expression="execution(* com.scxxs.dao.*.*(..))" /><aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod" /></aop:config><bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource"> <ref local="dataSource"/> </property> </bean><bean id="springDemoDao" class="com.scxxs.dao.impl.SpringDaoDemoImpl"><property name="jdbcTemplate" ref="jdbcTemplate" /></bean> </beans> 引用的jar 如图:我试过 引用 我原来 项目的老包的话 项目启动是没问题的,但是 换上 图上的新包后我的项目启动 报错:报错信息如下:java.lang.NoSuchMethodError: org.springframework.web.context.support.XmlWebApplicationContext.getEnvironment()Lorg/springframework/core/env/ConfigurableEnvironment;at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:87)at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467)at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397)at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:987)at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:909)at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:495)at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)at org.apache.catalina.core.StandardService.start(StandardService.java:516)at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)at org.apache.catalina.startup.Catalina.start(Catalina.java:583)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(Method.java:597)at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)2012-12-14 15:38:34 org.apache.catalina.core.StandardContext listenerStart严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListenerjava.lang.NoSuchMethodError: org.springframework.web.context.support.XmlWebApplicationContext.getEnvironment()Lorg/springframework/core/env/ConfigurableEnvironment;at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:87)at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467)at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397)at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3934)at org.apache.catalina.core.StandardContext.start(StandardContext.java:4429)at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:987)at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:909)at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:495)at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)at org.apache.catalina.core.StandardService.start(StandardService.java:516)at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)at org.apache.catalina.startup.Catalina.start(Catalina.java:583)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(Method.java:597)at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)2012-12-14 15:38:34 org.apache.catalina.core.StandardContext start严重: Error listenerStart2012-12-14 15:38:34 org.apache.catalina.core.StandardContext start严重: Context [/springdemo] startup failed due to previous errors2012-12-14 15:38:34 org.apache.catalina.core.ApplicationContext log信息: Closing Spring root WebApplicationContext2012-12-14 15:38:34Closing Root WebApplicationContext: startup date [Fri Dec 14 15:38:34 CST 2012]; root of context hierarchy2012-12-14 15:38:34Exception thrown from ApplicationListener handling ContextClosedEventjava.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date [Fri Dec 14 15:38:34 CST 2012]; root of context hierarchyat org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:316)at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:303)at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1007)at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:970)at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:556)at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:142)at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3973)at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4577)at org.apache.catalina.core.StandardContext.start(StandardContext.java:4474)at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:987)at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:909)at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:495)at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)at org.apache.catalina.core.StandardService.start(StandardService.java:516)at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)at org.apache.catalina.startup.Catalina.start(Catalina.java:583)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(Method.java:597)at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)2012-12-14 15:38:34Exception thrown from LifecycleProcessor on context closejava.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Fri Dec 14 15:38:34 CST 2012]; root of context hierarchyat org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:329)at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1015)at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:970)at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:556)at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:142)at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3973)at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4577)at org.apache.catalina.core.StandardContext.start(StandardContext.java:4474)at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:987)at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:909)at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:495)at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)at org.apache.catalina.core.StandardService.start(StandardService.java:516)at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)at org.apache.catalina.startup.Catalina.start(Catalina.java:583)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(Method.java:597)at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)2012-12-14 15:38:34 org.apache.catalina.core.StandardContext listenerStop严重: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListenerjava.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContextat org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:171)at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1048)at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1022)at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:970)at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:556)at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:142)at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:3973)at org.apache.catalina.core.StandardContext.stop(StandardContext.java:4577)at org.apache.catalina.core.StandardContext.start(StandardContext.java:4474)at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:526)at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:987)at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:909)at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:495)at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1206)at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:314)at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)at org.apache.catalina.core.StandardHost.start(StandardHost.java:722)at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)at org.apache.catalina.core.StandardService.start(StandardService.java:516)at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)at org.apache.catalina.startup.Catalina.start(Catalina.java:583)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(Method.java:597)at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)我就没明白 这是少包呢 还是怎么?我网上 找遍了 没找到解诀方案,不清楚原因啊 求接 谢谢 了!项目 只用了 spring
解决方案
ava.lang.NoSuchMethodError: org.springframework.web.context.support.XmlWebApplicationContext.getEnvironment()Lorg/springframework/core/env/ConfigurableEnvironment;at 缺org.springframework.context.support-3.1.1.RELEASE.jar
解决方案二:
解决方案三:
包冲突了。。。删掉com.springsource.org.apache.commons.logging-1.1.1.jar试试