启动应用程序时的Spring异常

时间:2011-12-27 12:48:40

标签: hibernate spring spring-mvc nhibernate-mapping

我已经从Vannilla参考了Spring Hibernate Integration Example。

当我使用应用程序启动Tomcat时,会发生以下错误:

27 Dec, 2011 6:08:22 PM org.apache.catalina.core.ApplicationContext log
SEVERE: StandardWrapper.Throwable
java.lang.NoSuchMethodError: org.springframework.web.context.ConfigurableWebApplicationContext.setId(Ljava/lang/String;)V
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:431)
    at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:459)
    at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:340)
    at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:307)
    at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
    at javax.servlet.GenericServlet.init(GenericServlet.java:212)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:809)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:129)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    at java.lang.Thread.run(Thread.java:662)

我根据自己的要求编辑了User类和数据库参数。

这是我的用户类:

package com.vaannila.domain;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="USERREGISTRATION_NEW")
public class User {

    private int id;
    private String userName;
    private String sex;
    private String phone;
    private String email;
    private Date dob;
    private String courses;
    private String exams;
    private String newsletter;
    private String createdDate;
    private int country_id;
    private int state_id;
    private int city_id;
    private String addressIP;


    @Id
    @GeneratedValue
    @Column(name="ID")
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }

    @Column(name="USERNAME")
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }


    @Column(name="SEX")
    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    @Column(name="PHONE")
    public String getPhone() {
        return phone;
    }
    public void setPhone(String phone) {
        this.phone = phone;
    }

    @Column(name="EMAIL")
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Column(name="DOB")
    public Date getDob() {
        return dob;
    }
    public void setDob(Date dob) {
        this.dob = dob;
    }
    @Column(name="COURSES")
    public String getCourses() {
        return courses;
    }
    public void setCourses(String courses) {
        this.courses = courses;
    }
    @Column(name="EXAMS")
    public String getExams() {
        return exams;
    }
    public void setExams(String exams) {
        this.exams = exams;
    }
    @Column(name="NEWSLETTER")
    public String getNewsletter() {
        return newsletter;
    }
    public void setNewsletter(String newsletter) {
        this.newsletter = newsletter;
    }
    @Column(name="CREATEDDATE")
    public String getCreatedDate() {
        return createdDate;
    }
    public void setCreatedDate(String createdDate) {
        this.createdDate = createdDate;
    }
    @Column(name="COUNTRY_ID")
    public int getCountry_id() {
        return country_id;
    }
    public void setCountry_id(int country_id) {
        this.country_id = country_id;
    }
    @Column(name="STATE_ID")
    public int getState_id() {
        return state_id;
    }
    public void setState_id(int state_id) {
        this.state_id = state_id;
    }

    @Column(name="CITY_ID")
    public int getCity_id() {
        return city_id;
    }
    public void setCity_id(int city_id) {
        this.city_id = city_id;
    }

    @Column(name="ADDRESSIP")
    public String getAddressIP() {
        return addressIP;
    }
    public void setAddressIP(String addressIP) {
        this.addressIP = addressIP;
    }   

}

我创建了所有的setter&每个变量的吸气剂。

然后仍然会在setID中显示错误

我无法理解为什么会出现这个问题?

1 个答案:

答案 0 :(得分:0)

此错误与您的User类无关,但我怀疑您的类路径中存在问题。检查所有弹簧罐是否都是相同的版本。