当前位置: 代码迷 >> J2EE >> s2sh 整合的错误
  详细解决方案

s2sh 整合的错误

热度:695   发布时间:2016-04-21 23:28:25.0
s2sh 整合的异常
Service类如下:
@Component //自己也要交给spring管理
public class TuserService {
private UserDao userDao;

public UserDao getUserDao() {
return userDao;
}

@Resource
public void setUserDao(UserDao userDao) {
this.userDao = userDao;
}

@Transactional(readOnly=true
public void add(Tuser user) {
userDao.save(user);
}

public static void main(String[] args) {
TuserService userService = (TuserService) new ClassPathXmlApplicationContext("applicationContext.xml").getBean("tuserService");
Tuser user = new Tuser();
user.setUserName("annot");
user.setUserPassword("annopassword");
userService.add(user);
}
}

Dao类如下:
@Component
public class UserDao extends SuperDao{   public void save(Tuser user) {
this.getHibernateTemplate().save(user);
}
}


结果运行service类的main函数就报异常:

Exception in thread "main" java.lang.NoSuchMethodError: org.springframework.beans.factory.annotation.InjectionMetadata.<init>(Ljava/lang/Class;Ljava/util/Collection;)V
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.findPersistenceMetadata(PersistenceAnnotationBeanPostProcessor.java:402)
at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessMergedBeanDefinition(PersistenceAnnotationBeanPostProcessor.java:320)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyMergedBeanDefinitionPostProcessors(AbstractAutowireCapableBeanFactory.java:745)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:448)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
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:222)
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.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.sc.service.TuserService.main(TuserService.java:32)

这是什么原因啊??
spring,annotation

------解决方案--------------------
NoSuchMethodError,没有匹配的方法,你看你的spring要用的jar包引进去没有,还有可能是jar包的冲突,我搭建的时候没有遇到过这样的问题,其他的问题倒遇到很多。
  相关解决方案