我在eclipse中创建了一个maven项目,当我尝试在项目目录中运行mvn clean install时会出现这样的错误:
[INFO] Compiling 3 source files to C:\Users\Florin\Documents\Facultate\Master\TM
IS\Anul1\Sem2\ORM\Teme\Lab1_5\shop-interfaces\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/Florin/Documents/Facultate/Master/TMIS/Anul1/Sem2/ORM/Teme/Lab
1_5/shop-interfaces/src/main/java/ro/unitbv/IShoppingCart.java:[5,17] package ja
vax.ejb does not exist
[ERROR] /C:/Users/Florin/Documents/Facultate/Master/TMIS/Anul1/Sem2/ORM/Teme/Lab
1_5/shop-interfaces/src/main/java/ro/unitbv/IShoppingCart.java:[7,2] cannot find
symbol
symbol: class Remote
[ERROR] /C:/Users/Florin/Documents/Facultate/Master/TMIS/Anul1/Sem2/ORM/Teme/Lab
1_5/shop-interfaces/src/main/java/ro/unitbv/ProductDao.java:[6,17] package javax
.ejb does not exist
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.
1:compile (default-compile) on project shop-interfaces: Compilation failure: Com
pilation failure:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.
1:compile (default-compile) on project shop-interfaces: Compilation failure: Com
pilation failure:
[ERROR] /C:/Users/Florin/Documents/Facultate/Master/TMIS/Anul1/Sem2/ORM/Teme/Lab
1_5/shop-interfaces/src/main/java/ro/unitbv/IShoppingCart.java:[5,17] package ja
vax.ejb does not exist
...
我检查了是否下载了包javax.ejb,它是否存在于.m2文件夹中。
编辑: 我的pom文件是:
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ro.unitbv</groupId>
<artifactId>shop-interfaces</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>shop-interfaces</name>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>povided</scope>
</dependency>
</dependencies>
</project>
答案 0 :(得分:6)
根据您真正需要的内容,您必须定义javax.ejb
中未定义javaee-api
的依赖关系。
你必须举例:
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>javax.ejb-api</artifactId>
<version>3.2</version>
<scope>provided</scope>
</dependency>