我在多模块 Maven 项目中遇到错误。我尝试通过 eclipse run 作为选项运行“maven install”。
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building mysite-entities 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ mysite-entities ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/thomas/spring/mysite-parent/mysite-entities/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ mysite-entities ---
[INFO] Compiling 11 source files to /home/thomas/spring/mysite-parent/mysite-entities/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/thomas/spring/mysite-parent/mysite-entities/src/main/java/com/mysite/entities/Mcc.java:[5,24] package javax.persistence does not exist
[ERROR] /home/thomas/spring/mysite-parent/mysite-entities/src/main/java/com/mysite/entities/Mcc.java:[6,24] package javax.persistence does not exist
[ERROR] /home/thomas/spring/mysite-parent/mysite-entities/src/main/java/com/mysite/entities/Mcc.java:[8,1] cannot find symbol
symbol: class Entity
@Entity
mcc.java:
package com.mysite.entities;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class Mcc implements Serializable
{
/**
*
*/
private static final long serialVersionUID = 4146710247449711520L;
@Id
private Long id;
private String name;
public Long getId()
{
return id;
}
public void setId(Long id)
{
this.id = id;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
}
我的 pom.xml 包括:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
我检查了引入的 Maven 依赖项,它们包括 hibernate-jpa-2.0-api-1.0.1.Final.jar ,它又包括所有必要的类。
为什么我会收到这个 Maven 错误?