我努力摆脱这个错误,但它不想离开我。
这是配置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:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:lang="http://www.springframework.org/schema/lang"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
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/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<context:annotation-config />
<context:component-scan base-package="net.viralpatel.contact" />
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="classpath:messages" />
<property name="defaultEncoding" value="UTF-8" />
</bean>
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
p:location="/WEB-INF/jdbc.properties" />
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
p:driverClassName="${jdbc.driverClassName}"
p:url="${jdbc.databaseurl}" p:username="${jdbc.username}"
p:password="${jdbc.password}" />
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration</value>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${jdbc.dialect}</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<tx:annotation-driven />
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
</beans>
当我尝试运行该项目时,我收到此错误
例外
javax.servlet.ServletException:servlet spring 的 Servlet.init() 抛出异常 org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java: 98) org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) org.apache.coyote.http11.AbstractHttp11Processor.process( AbstractHttp11Processor.java:999) org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565) org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309) java.util. concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)java.lang.Thread.run(线程.java:722)
根本原因
org.springframework.beans.factory.BeanCreationException:在 ServletContext 资源 [/WEB-INF/spring-servlet.xml] 中创建名称为“messageSource”的 bean 时出错:bean 实例化之前的 BeanPostProcessor 失败;嵌套异常是 java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:457) org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295) org.springframework.beans.factory.support .DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198 ) org.springframework.context.support.AbstractApplicationContext.initMessageSource(AbstractApplicationContext.java:786) org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:467) org.springframework.web.servlet。FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:652) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:600) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:666) org.springframework。 web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:519) org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:460) org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) javax.servlet.GenericServlet.init(GenericServlet.java:160) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) org.apache.catalina.valves。AccessLogValve.invoke(AccessLogValve.java:927) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999) org.apache。 coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565) org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:第1110章)AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565) org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) java.lang.Thread.run(Thread.java:722)AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565) org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) java.lang.Thread.run(Thread.java:722)
根本原因
java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.isInfrastructureClass(AbstractAutoProxyCreator.java:384) org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java :276) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:894) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:866) org.springframework.beans.factory .support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:451) org.springframework.beans.factory.support.AbstractBeanFactory$1。getObject(AbstractBeanFactory.java:295) org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223) org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292) org. springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:198) org.springframework.context.support.AbstractApplicationContext.initMessageSource(AbstractApplicationContext.java:786) org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext. java:467) org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:652) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:600) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:666) org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:519) org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java: 460)org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136)javax.servlet.GenericServlet.init(GenericServlet.java:160)org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:第472章) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) CoyoteAdapter.java:407) org.apache.coyote.http11.AbstractHttp11Processor。进程(AbstractHttp11Processor.java:999)org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)java。 util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) java.lang.Thread.run(Thread.java:722)
我的消息属性文件位于类路径的资源包中。有人请告诉我我缺少什么我还添加了aopalliance-alpha1.jar