我需要你的帮助来使用PostgresSQL数据库将实体映射到表,实际上导致这个错误的原因是我试图将一个实体映射到表,不幸的是maven导致了这个我无法识别的问题,
因此,我必须先使用代码,然后使用jpa、persistence.xml和jboss wildfly将这个实体映射到postgresql中的表。提前感谢你的支持。

package testdb;

import java.io.Serializable;
import javax.persistence.*;


/**
 * The persistent class for the "HAHA" database table.
 *
 */
@Entity
@Table(name="Ha_ha", schema="public")
public class Haha implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @Column(name="ID_HAHA")
    private long idHaha;

    @Column(name="DESIGNATION")
    private String designation;

    public Haha() {
    }

    public long getIdHaha() {
        return this.idHaha;
    }

    public void setIdHaha(long idHaha) {
        this.idHaha = idHaha;
    }

    public String getDesignation() {
        return this.designation;
    }

    public void setDesignation(String designation) {
        this.designation = designation;
    }

}

下面是一个错误消息的示例,与maven的输出完全相同:
[ERROR] COMPILATION ERROR :
    [INFO] -------------------------------------------------------------
    [ERROR] /C:/Users/anonyme/eclipse-workspace/testdb/src/testdb/Haha.java:[4,1] package javax.persistence does not exist
    [ERROR] /C:/Users/anonyme/eclipse-workspace/testdb/src/testdb/Haha.java:[11,2] cannot find symbol
      symbol: class Entity
    [ERROR] /C:/Users/anonyme/eclipse-workspace/testdb/src/testdb/Haha.java:[12,2] cannot find symbol
      symbol: class Table
    [ERROR] /C:/Users/anonyme/eclipse-workspace/testdb/src/testdb/Haha.java:[16,10] cannot find symbol
      symbol:   class Id
      location: class testdb.Haha
    [ERROR] /C:/Users/anonyme/eclipse-workspace/testdb/src/testdb/Haha.java:[17,10] cannot find symbol
      symbol:   class Column
      location: class testdb.Haha
    [ERROR] /C:/Users/anonyme/eclipse-workspace/testdb/src/testdb/Haha.java:[20,10] cannot find symbol
      symbol:   class Column
      location: class testdb.Haha
    [INFO] 6 errors
    [INFO] -------------------------------------------------------------
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 4.759 s
    [INFO] Finished at: 2017-11-19T02:12:34+01:00
    [INFO] Final Memory: 17M/211M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project testdb: Compilation failure: Compilation failure:
    [ERROR] /C:/Users/anonyme/eclipse-workspace/testdb/src/testdb/Haha.java:[4,1] package javax.persistence does not exist
    [ERROR] /C:/Users/anonyme/eclipse-workspace/testdb/src/testdb/Haha.java:[11,2] cannot find symbol
    [ERROR] symbol: class Entity
    [ERROR] /C:/Users/anonyme/eclipse-workspace/testdb/src/testdb/Haha.java:[12,2] cannot find symbol
    [ERROR] symbol: class Table
    [ERROR] /C:/Users/anonyme/eclipse-workspace/testdb/src/testdb/Haha.java:[16,10] cannot find symbol
    [ERROR] symbol:   class Id
    [ERROR] location: class testdb.Haha
    [ERROR] /C:/Users/anonyme/eclipse-workspace/testdb/src/testdb/Haha.java:[17,10] cannot find symbol
    [ERROR] symbol:   class Column
    [ERROR] location: class testdb.Haha
    [ERROR] /C:/Users/anonyme/eclipse-workspace/testdb/src/testdb/Haha.java:[20,10] cannot find symbol
    [ERROR] symbol:   class Column
    [ERROR] location: class testdb.Haha
    [ERROR] -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

最佳答案

看起来您需要将this dependency添加到您的Maven项目中。

<dependency>
    <groupId>javax.persistence</groupId>
    <artifactId>persistence-api</artifactId>
    <version>1.0.2</version>
</dependency>

08-06 10:09