错误信息:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'registDaoImpl': 
Injection of resource methods failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [beans.xml]: Invocation of init method failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.hibernate.cfg.AnnotationConfiguration]: Constructor threw exception;
 nested exception is java.lang.NoSuchFieldError: INSTANCE
我的beans.xml如下:<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-2.5.xsd
           http://www.springframework.org/schema/aop
           http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
  <context:annotation-config />
  <context:component-scan base-package="com.ershou" />
  
  <bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>classpath:jdbc.properties</value>
</property>
</bean> <bean id="dataSource" destroy-method="close"
class="org.apache.commons.dbcp.BasicDataSource">
<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> <bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan">
<list>
<value>com.ershou.model</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
</beans>我的RegistAction类:package com.ershou.action;
import javax.annotation.Resource;import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;import com.ershou.model.User;
import com.ershou.service.RegistService;
import com.opensymphony.xwork2.ActionSupport;
public class RegistAction extends ActionSupport {
private static final long serialVersionUID = 1L;
private RegistService registService;
private User user;

public RegistService getRegistService() {
return registService;
}

    @Resource(name="r")
public void setRegistService(RegistService registService) {
this.registService = registService;
} public User getUser() {
return user;
} public void setUser(User user) {
this.user= user;
} public String regist(){
   System.out.println(user.getEmail());
   System.out.println(user.getClass());
   ApplicationContext ctx=new ClassPathXmlApplicationContext("beans.xml");
RegistService registService=(RegistService)ctx.getBean("r");
   System.out.println(registService.getClass());
   registService.add(user);
   System.out.println(user.getEmail());
   return SUCCESS;

}
}我的RegistService类:package com.ershou.service;import javax.annotation.Resource;import org.springframework.stereotype.Component;import com.ershou.dao.RegistDao;
import com.ershou.model.User;@Component("r")
public class RegistService {
private RegistDao registDao; public RegistDao getRegistDao() {
return registDao;
}

    @Resource(name="registDaoImpl")
public void setRegistDao(RegistDao registDao) {
this.registDao = registDao;
} public void add(User user) {
this.registDao.add(user);
}

public void dayin(){
System.out.print("!!!");
}}我的RegistDaoImpl类:package com.ershou.dao.impl;
import javax.annotation.Resource;import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Component;import com.ershou.dao.RegistDao;
import com.ershou.model.User;@Component("registDaoImpl")
public class RegistDaoImpl implements RegistDao {

private SessionFactory sessionFactory;

    public SessionFactory getSessionFactory() {
return sessionFactory;
}
     
    @Resource(name="sessionFactory")
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
} //添加注册用户方法
public void add(User user) {
// TODO Auto-generated method stub
Session s = sessionFactory.openSession();
s.save(user);
}}
注册页面主要代码:<form action="user/regist!regist" method="post">
<p>用户名:<input name="user.username" type="text" /><br />
   密  码:<input name="user.password" type="text" /><br/>
   邮  箱:<input name="user.email" type="text" /><br />
<input value="提交" type="submit"/>
<input value="重置" type="reset"/>  
</form>我的一些jar包:struts中的jar包:commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
commons-logging-1.0.4.jar
freeer-2.3.13.jar
ognl-2.6.11.jar
struts2-core-2.1.6.jar
xwork-2.1.2.jarhibernate中的一些jar包:antlr-2.7.6.jar
commons-collections-3.1.jar
dom4j-1.6.1.jar
javassist-3.12.0.GA.jar
jta-1.1.jar
slf4j-api-1.6.1.jar
slf4j-nop-1.6.1.jar
mysql-connector-java-5.1.17-bin.jar
hibernate3.jar
hibernate-jpa-2.0-api-1.0.0.Final.jarsping中的一些包:spring.jar
commons-dbcp.jar
commons-pool.jar
common-annotations.jar
log4j-1.2.15.jar
通过注册页面访问RegistAction的regist方法就报上面的错,是不能进行初始化bean,但找了半天没有找到原因,我用测试实例可以将数据存入数据库,没有报错,测试代码如下:
@Test
public void save1(){
ApplicationContext ctx=new ClassPathXmlApplicationContext("beans.xml");
RegistService service=(RegistService)ctx.getBean("r");
User user=new User();
user.setName("YU");
user.setEmail("123");
service.add(user);
service.dayin();
}各位好心的大侠帮帮忙吧!小弟感激不尽啊!