关于网友提出的“ 关于SSH的一些错误总是感到莫名奇妙,大家帮忙解决下”问题疑问,本网通过在网上对“ 关于SSH的一些错误总是感到莫名奇妙,大家帮忙解决下”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:
问题: 关于SSH的一些错误总是感到莫名奇妙,大家帮忙解决下描述:
学SSH真郁闷,有时候错误会莫名奇妙,比如前些天我把
改为code=Java]update
开始测试没问题,然后猛的初始化Spring的容器都报错,就是ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");这一句。现在这个错误是:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'proService': Injection of resource methods failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateTemplate' defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:275)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1030)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
.....
我的bean.xml文件:
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:c/>
classpath:jdbc.properties
<>
class="org.apache.commons.dbcp.BasicDataSource">
<>
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
com.rh.bean.product.ProductType
org.hibernate.dialect.MySQLDialect
thread
true
update
用到的实体类的代码:
package com.rh.bean.product;,请大家帮忙找下错误啊。谢谢
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
@Entity
public class ProductType {
private Integer typeid;
/**类别名称*/
private String name;
/**在google上 的描述*/
private String note;
/**是否可见*/
private Boolean visible=true;
/**得到所有子类别*/
private Setchildtypes=new HashSet ();
/**所属父类*/
private ProductType parent;
@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
public Integer getTypeid() {
return typeid;
}
public void setTypeid(Integer typeid) {
this.typeid = typeid;
}
@Column(length=36,nullable=false)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(length=100)
public String getNote() {
return note;
}
public void setNote(String note) {
this.note = note;
}
@Column(nullable=true)
public Boolean getVisible() {
return visible;
}
public void setVisible(Boolean visible) {
this.visible = visible;
}
@OneToMany(cascade={CascadeType.REMOVE,CascadeType.REFRESH})
public SetgetChildtypes() {
return childtypes;
}
public void setChildtypes(SetchildTypes) {
this.childtypes = childTypes;
}
@ManyToOne(opti /> @JoinColumn(name="parentid")
public ProductType getParent() {
return parent;
}
public void setParent(ProductType parent) {
this.parent = parent;
}
}