JAVA spring 框架 调试

wenwen1 发布于 2012/10/10 16:52
阅读 1K+
收藏 0

我在我的generated中的net.gvsun.preparation.domain.中的Project.java如下:

package net.gvsun.preparation.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import java.util.Calendar;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import org.codehaus.jackson.annotate.JsonIgnore;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

/**
 */

@Entity
@NamedQueries({
        @NamedQuery(name = "findAllProjects", query = "select myProject from Project myProject"),
        @NamedQuery(name = "findProjectByCreateDate", query = "select myProject from Project myProject where myProject.createDate = ?1"),
        @NamedQuery(name = "findProjectById", query = "select myProject from Project myProject where myProject.id = ?1"),
        @NamedQuery(name = "findProjectByPrimaryKey", query = "select myProject from Project myProject where myProject.id = ?1"),
        @NamedQuery(name = "findProjectByProjectName", query = "select myProject from Project myProject where myProject.projectName = ?1"),
        @NamedQuery(name = "findProjectByProjectNameContaining", query = "select myProject from Project myProject where myProject.projectName like ?1"),
        @NamedQuery(name = "findProjectByProjectNo", query = "select myProject from Project myProject where myProject.projectNo = ?1"),
        @NamedQuery(name = "findProjectByProjectNoContaining", query = "select myProject from Project myProject where myProject.projectNo like ?1"),
        @NamedQuery(name = "findProjectBySpecification", query = "select myProject from Project myProject where myProject.specification = ?1"),
        @NamedQuery(name = "findProjectBySpecificationContaining", query = "select myProject from Project myProject where myProject.specification like ?1") })
@Table(catalog = "pms", name = "project")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "preparation/net/gvsun/preparation/domain", name = "Project")
@XmlRootElement(namespace = "preparation/net/gvsun/preparation/domain")
public class Project implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 项目编号
     *
     */

    @Column(name = "ID", nullable = false)
    @Basic(fetch = FetchType.EAGER)
    @Id
    @XmlElement
    @GeneratedValue(strategy=GenerationType.AUTO)
    Integer id;
    /**
     * 项目名称
     *
     */

    @Column(name = "Project_Name")
    @Basic(fetch = FetchType.EAGER)
    @XmlElement
    String projectName;
    /**
     * 创建日期
     *
     */
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "Create_DATE")
    @Basic(fetch = FetchType.EAGER)
    @XmlElement
    Calendar createDate;
    /**
     * 描述
     *
     */

    @Column(name = "Specification")
    @Basic(fetch = FetchType.EAGER)
    @XmlElement
    String specification;
    /**
     * 项目编号
     *
     */

    @Column(name = "Project_No")
    @Basic(fetch = FetchType.EAGER)
    @XmlElement
    String projectNo;

    /**
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumns({ @JoinColumn(name = "Creater", referencedColumnName = "ID") })
    @XmlTransient
    User userByCreater;
    /**
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumns({ @JoinColumn(name = "Statue_ID", referencedColumnName = "ID") })
    @XmlTransient
    CStatue CStatue;
    /**
     */
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumns({ @JoinColumn(name = "Responser", referencedColumnName = "ID") })
    @XmlTransient
    User userByResponser;
    /**
     */
    @OneToMany(mappedBy = "project", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
    @XmlElement(name = "", namespace = "")
    java.util.Set<net.gvsun.preparation.domain.Task> tasks;
    /**
     */
    @OneToMany(mappedBy = "project", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
    @XmlElement(name = "", namespace = "")
    java.util.Set<net.gvsun.preparation.domain.ProjectApplication> projectApplications;
    /**
     */
    @OneToMany(mappedBy = "project", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
    @XmlElement(name = "", namespace = "")
    java.util.Set<net.gvsun.preparation.domain.ProjectSchedule> projectSchedules;
    /**
     */
    @OneToMany(mappedBy = "project", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
    @XmlElement(name = "", namespace = "")
    java.util.Set<net.gvsun.preparation.domain.Document> documents;
    /**
     */
    @OneToMany(mappedBy = "project", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
    @XmlElement(name = "", namespace = "")
    java.util.Set<net.gvsun.preparation.domain.ProjectFinance> projectFinances;
    /**
     */
    @OneToOne(mappedBy = "project", fetch = FetchType.LAZY)
    @XmlElement(name = "", namespace = "")
    ProjectArtical projectArtical;

    /**
     * 项目编号
     *
     */
    public void setId(Integer id) {
        this.id = id;
    }

    /**
     * 项目编号
     *
     */
    public Integer getId() {
        return this.id;
    }

    /**
     * 项目名称
     *
     */
    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    /**
     * 项目名称
     *
     */
    public String getProjectName() {
        return this.projectName;
    }

    /**
     * 创建日期
     *
     */
    public void setCreateDate(Calendar createDate) {
        this.createDate = createDate;
    }

    /**
     * 创建日期
     *
     */
    public Calendar getCreateDate() {
        return this.createDate;
    }

    /**
     * 描述
     *
     */
    public void setSpecification(String specification) {
        this.specification = specification;
    }

    /**
     * 描述
     *
     */
    public String getSpecification() {
        return this.specification;
    }

    /**
     * 项目编号
     *
     */
    public void setProjectNo(String projectNo) {
        this.projectNo = projectNo;
    }

    /**
     * 项目编号
     *
     */
    public String getProjectNo() {
        return this.projectNo;
    }

    /**
     */
    public void setUserByCreater(User userByCreater) {
        this.userByCreater = userByCreater;
    }

    /**
     */
    @JsonIgnore
    public User getUserByCreater() {
        return userByCreater;
    }

    /**
     */
    public void setCStatue(CStatue CStatue) {
        this.CStatue = CStatue;
    }

    /**
     */
    @JsonIgnore
    public CStatue getCStatue() {
        return CStatue;
    }

    /**
     */
    public void setUserByResponser(User userByResponser) {
        this.userByResponser = userByResponser;
    }

    /**
     */
    @JsonIgnore
    public User getUserByResponser() {
        return userByResponser;
    }

    /**
     */
    public void setTasks(Set<Task> tasks) {
        this.tasks = tasks;
    }

    /**
     */
    @JsonIgnore
    public Set<Task> getTasks() {
        if (tasks == null) {
            tasks = new java.util.LinkedHashSet<net.gvsun.preparation.domain.Task>();
        }
        return tasks;
    }

    /**
     */
    public void setProjectApplications(Set<ProjectApplication> projectApplications) {
        this.projectApplications = projectApplications;
    }

    /**
     */
    @JsonIgnore
    public Set<ProjectApplication> getProjectApplications() {
        if (projectApplications == null) {
            projectApplications = new java.util.LinkedHashSet<net.gvsun.preparation.domain.ProjectApplication>();
        }
        return projectApplications;
    }

    /**
     */
    public void setProjectSchedules(Set<ProjectSchedule> projectSchedules) {
        this.projectSchedules = projectSchedules;
    }

    /**
     */
    @JsonIgnore
    public Set<ProjectSchedule> getProjectSchedules() {
        if (projectSchedules == null) {
            projectSchedules = new java.util.LinkedHashSet<net.gvsun.preparation.domain.ProjectSchedule>();
        }
        return projectSchedules;
    }

    /**
     */
    public void setDocuments(Set<Document> documents) {
        this.documents = documents;
    }

    /**
     */
    @JsonIgnore
    public Set<Document> getDocuments() {
        if (documents == null) {
            documents = new java.util.LinkedHashSet<net.gvsun.preparation.domain.Document>();
        }
        return documents;
    }

    /**
     */
    public void setProjectFinances(Set<ProjectFinance> projectFinances) {
        this.projectFinances = projectFinances;
    }

    /**
     */
    @JsonIgnore
    public Set<ProjectFinance> getProjectFinances() {
        if (projectFinances == null) {
            projectFinances = new java.util.LinkedHashSet<net.gvsun.preparation.domain.ProjectFinance>();
        }
        return projectFinances;
    }

    /**
     */
    public void setProjectArtical(ProjectArtical projectArtical) {
        this.projectArtical = projectArtical;
    }

    /**
     */
    @JsonIgnore
    public ProjectArtical getProjectArtical() {
        return projectArtical;
    }

    /**
     */
    public Project() {
    }

    /**
     * Copies the contents of the specified bean into this bean.
     *
     */
    public void copy(Project that) {
        setId(that.getId());
        setProjectName(that.getProjectName());
        setCreateDate(that.getCreateDate());
        setSpecification(that.getSpecification());
        setProjectNo(that.getProjectNo());
        setUserByCreater(that.getUserByCreater());
        setCStatue(that.getCStatue());
        setUserByResponser(that.getUserByResponser());
        setTasks(new java.util.LinkedHashSet<net.gvsun.preparation.domain.Task>(that.getTasks()));
        setProjectApplications(new java.util.LinkedHashSet<net.gvsun.preparation.domain.ProjectApplication>(that.getProjectApplications()));
        setProjectSchedules(new java.util.LinkedHashSet<net.gvsun.preparation.domain.ProjectSchedule>(that.getProjectSchedules()));
        setDocuments(new java.util.LinkedHashSet<net.gvsun.preparation.domain.Document>(that.getDocuments()));
        setProjectFinances(new java.util.LinkedHashSet<net.gvsun.preparation.domain.ProjectFinance>(that.getProjectFinances()));
        setProjectArtical(that.getProjectArtical());
    }

    /**
     * Returns a textual representation of a bean.
     *
     */
    public String toString() {

        StringBuilder buffer = new StringBuilder();

        buffer.append("id=[").append(id).append("] ");
        buffer.append("projectName=[").append(projectName).append("] ");
        buffer.append("createDate=[").append(createDate).append("] ");
        buffer.append("specification=[").append(specification).append("] ");
        buffer.append("projectNo=[").append(projectNo).append("] ");

        return buffer.toString();
    }

    /**
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = (int) (prime * result + ((id == null) ? 0 : id.hashCode()));
        return result;
    }

    /**
     */
    public boolean equals(Object obj) {
        if (obj == this)
            return true;
        if (!(obj instanceof Project))
            return false;
        Project equalCheck = (Project) obj;
        if ((id == null && equalCheck.id != null) || (id != null && equalCheck.id == null))
            return false;
        if (id != null && !id.equals(equalCheck.id))
            return false;
        return true;
    }
}

然后我在红色代码下面加入以下代码

/**

     */
    @OneToMany(mappedBy = "project", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)
    @XmlElement(name = "", namespace = "")

    java.util.Set<net.gvsun.preparation.domain.Authority> authoritys;

为什么会报如下错误:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'AuthorityDAO': Injection of persistence dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pms' defined in class path resource [preparation-dao-context.xml]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: net.gvsun.preparation.domain.Authority.project in net.gvsun.preparation.domain.Project.authoritys
    at org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor.postProcessPropertyValues(PersistenceAnnotationBeanPostProcessor.java:342)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:848)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:478)
    ... 39 more

而且在浏览器中输入http://localhost:8080/preparation/就会

HTTP Status 404 -

type Status report

message

description The requested resource () is not available.

怎么解决啊?

加载中
0
Gillian_Male
Gillian_Male
是缺少包么?还是包之间有冲突?
0
Gillian_Male
Gillian_Male
难道你的配置文件有问题?
返回顶部
顶部