标题翻译
The package *** is accessible from more than one module
问题
我在Ubuntu 19.10上使用Visual Studio Code 1.4.3,搭配Maven 3.6.3和GraalVM graalvm-ce-java11-20.0.0。我的Java项目的静态分析给出了以下错误:
包org.graalvm.polyglot可以从多个模块访问:<unnamed>、org.graalvm.sdk
我不知道<unnamed>
指的是哪个包,也不知道在哪里解决“重复导入”的问题。
注:如果我直接从终端使用mvn
编译项目,则不会出现此错误,但实际上这似乎是javac编译器的一个错误,详见此问题。
更新
上述错误会在每个源文件中被Visual Studio Code引发,在那些我从org.graalvm.polyglot
导入内容的地方(例如,import org.graalvm.polyglot.Value;
),而我的$CLASSPATH
变量目前为空。
更新
当前在pom.xml
内,我有以下内容:
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>graal-sdk</artifactId>
<version>${graalvm.version}</version>
</dependency>
<dependency>
<groupId>org.graalvm.truffle</groupId>
<artifactId>truffle-api</artifactId>
<version>${graalvm.version}</version>
</dependency>-->
通过尝试和错误,我发现我需要删除两个依赖项才能摆脱上述错误,但这样一来,我就会在com.oracle.truffle
内的任何内容上出现导入错误(例如,无法解析import com.oracle.truffle.api
)。
更新:
从终端运行mvn clean package install -DskipTests
可以编译项目而不会有任何投诉。
英文翻译
I'm using Visual Studio Code 1.4.3 on Ubuntu 19.10 with Maven 3.6.3 and GraalVM graalvm-ce-java11-20.0.0.
The static analysis of my java project gives me this error:
The package org.graalvm.polyglot is accessible from more than one module: <unnamed>, org.graalvm.sdk
I don't know which package does <unnamed>
refer to and where to look to solve the "double import" problem.
N.B.: this error does no happen if I compile my project directly using mvn
from terminal, but this actually seems to be a bug of the javac compiler, see this issue.
UPDATE
The above error is raised by Visual Studio Code in each source file where I import something from org.graalvm.polyglot
(e.g., import org.graalvm.polyglot.Value;
) and my $CLASSPATH
variable is currently empty.
UPDATE
Currently inside pom.xml
I have
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>graal-sdk</artifactId>
<version>${graalvm.version}</version>
</dependency>
<dependency>
<groupId>org.graalvm.truffle</groupId>
<artifactId>truffle-api</artifactId>
<version>${graalvm.version}</version>
</dependency>-->
By trial and errors I hav found that I need to remove both dependencies in order to get rid of the error above, but in this way I get an import error for anything inside com.oracle.truffle
(e.g., The import com.oracle.truffle.api cannot be resolved
)
UPDATE:
Running mvn clean package install -DskipTests
from terminal compiles the project without any complaint.
专注分享java语言的经验与见解,让所有开发者获益!
评论