`package org.jetbrains.annotations` 不存在。

huangapple go评论65阅读模式
英文:

package org.jetbrains.annotations does not exist

问题

我在使用IntelliJ构建项目时遇到了问题,当我尝试使用Maven进行构建时:

mvn clean install

我已经尝试了不同的方法,比如更改JDK的路径,但都没有成功。有人能帮我解决这个问题吗?

英文:

I am facing an issue in IntelliJ when I tried to build my project through maven using

mvn clean install

I have tried different ways like changing the path of my JDK but nothing worked. Can someone help me out with this issue?

答案1

得分: 5

如果有人在IntelliJ IDEA中使用纯Kotlin项目(没有使用任何构建工具,如Maven或Gradle),那么您可以按照以下步骤添加JetBrains的jetbrains.annotations库:

  1. 在左侧的项目面板中,右键单击模块,然后选择打开模块设置
  2. 项目设置下选择
  3. 在库区域顶部点击+符号,然后选择从Maven...
  4. 输入org.jetbrains:annotations,并点击末尾的搜索图标。然后等待下拉菜单列出可用版本。
  5. 选择您需要的最新或适当的版本,同时启用下载到:选项。
  6. 然后,点击确定,完成操作。
英文:

If anyone is using a plain Kotlin project (without any build tool such as maven or gradle) in IntelliJ IDEA, then you can add the jetbrain's jetbrains.annotations library by following the steps given below:

  1. Right click on the module in the Project panel on your left hand side, and select the Open module settings
  2. Select Libraries under Project settings
  3. Click the + symbol on the top of the library area and select the From Maven...
  4. Enter org.jetbrains:annotations, and hit the search icon at the end of it. Then, wait for the dropdown to list the available versions of it.
  5. Select the latest or appropriate version you need and also enable the Download to: option.
  6. Then, click OK and you are done.

答案2

得分: 3

如果您确实需要它们,请在您的 pom.xml 文件中添加依赖:

<!-- https://mvnrepository.com/artifact/org.jetbrains/annotations -->
<dependency>
    <groupId>org.jetbrains</groupId>
    <artifactId>annotations</artifactId>
    <version>16.0.1</version>
</dependency>

(链接:https://mvnrepository.com/artifact/org.jetbrains/annotations/16.0.1)

英文:

If you really need them, add the dependency in your pom.xml :

&lt;!-- https://mvnrepository.com/artifact/org.jetbrains/annotations --&gt;
&lt;dependency&gt;
    &lt;groupId&gt;org.jetbrains&lt;/groupId&gt;
    &lt;artifactId&gt;annotations&lt;/artifactId&gt;
    &lt;version&gt;16.0.1&lt;/version&gt;
&lt;/dependency&gt;

( https://mvnrepository.com/artifact/org.jetbrains/annotations/16.0.1 )

答案3

得分: 2

对我来说,添加 jetbrains 依赖项正常工作。

提供类似以下方式的依赖项。

对于 Gradle:

implementation 'org.jetbrains:annotations:16.0.2'
英文:

For me adding jetbrains dependency worked fine.

Provide dependency something like this.

For Gradle:

implementation &#39;org.jetbrains:annotations:16.0.2&#39;

答案4

得分: 2

将这段代码放入build.gradle中,它就会起作用。

implementation 'org.jetbrains:annotations:16.0.2'

英文:

just put this code in the build gradle and it will work.

implementation 'org.jetbrains:annotations:16.0.2'

答案5

得分: 0

我曾经遇到相同的问题,于是我在这里寻找解决方案,但是我找不到之前提到的pom.xml文件。可能是因为我在项目中没有使用Maven。但我通过编辑MyProject.iml文件来解决了这个问题。
我在<component>标签内添加了如下代码:

<orderEntry type="module-library">
  <library>
    <CLASSES>
      <root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/20.1.0/annotations-20.1.0.jar!/" />
    </CLASSES>
    <JAVADOC />
    <SOURCES />
  </library>
</orderEntry>

现在我可以在项目中使用这些注释了。
英文:

I had the same issue and arrived here looking for solutions, but I couldn't find the aforementioned pom.xml. Maybe because I'm not using Maven in my project. But I solved it by editing the MyProject.iml file.
I've added the following code inside the &lt;component&gt; tags.

&lt;orderEntry type=&quot;module-library&quot;&gt;
  &lt;library&gt;
    &lt;CLASSES&gt;
      &lt;root url=&quot;jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/20.1.0/annotations-20.1.0.jar!/&quot; /&gt;
    &lt;/CLASSES&gt;
    &lt;JAVADOC /&gt;
    &lt;SOURCES /&gt;
  &lt;/library&gt;
&lt;/orderEntry&gt;

Now I can use the annotations in my project.

huangapple
  • 本文由 发表于 2020年10月5日 17:08:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/64205627.html
匿名

发表评论

匿名网友

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

确定