这个包 *** 可从多个模块访问。

huangapple 未分类评论51阅读模式
标题翻译

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: &lt;unnamed&gt;, org.graalvm.sdk

I don't know which package does &lt;unnamed&gt; 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

&lt;dependency&gt;
  &lt;groupId&gt;org.graalvm.sdk&lt;/groupId&gt;
  &lt;artifactId&gt;graal-sdk&lt;/artifactId&gt;
  &lt;version&gt;${graalvm.version}&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
  &lt;groupId&gt;org.graalvm.truffle&lt;/groupId&gt;
  &lt;artifactId&gt;truffle-api&lt;/artifactId&gt;
  &lt;version&gt;${graalvm.version}&lt;/version&gt;
&lt;/dependency&gt;--&gt;

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.

huangapple
  • 本文由 发表于 2020年3月16日 18:00:33
  • 转载请务必保留本文链接:https://java.coder-hub.com/60703832.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定