包 org.jetbrains.annotations 不存在

问题描述 投票:0回答:5

当我尝试使用 Maven 通过 Maven 构建项目时,我在 IntelliJ 中遇到了问题

mvn clean install

我尝试了不同的方法,例如更改 JDK 的路径,但没有任何效果。有人可以帮我解决这个问题吗?

java intellij-idea jetbrains-ide
5个回答
5
投票

如果有人在 IntelliJ IDEA 中使用普通的

Kotlin
项目(没有任何构建工具,如 maven 或 gradle),那么您可以按照以下步骤添加 jetbrain 的
jetbrains.annotations
库:

  1. 右键单击左侧
    Project
    面板中的模块,然后选择
    Open module settings
  2. 选择
    Libraries
     下的 
    Project settings
  3. 单击库区域顶部的
    +
    符号,然后选择
    From Maven...
  4. 输入
    org.jetbrains:annotations
    ,然后点击其末尾的搜索图标。然后,等待下拉列表列出其可用版本。
  5. 选择您需要的最新或适当的版本,并启用
    Download to:
    选项。
  6. 然后,单击
    OK
    即可完成。

4
投票

如果您确实需要它们,请在 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


3
投票

对我来说,添加

jetbrains
依赖关系效果很好。

提供类似这样的依赖。

对于 Gradle:

implementation 'org.jetbrains:annotations:16.0.2'

2
投票

只需将此代码放入构建 gradle 中即可运行。

实现“org.jetbrains:annotations:16.0.2”


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>

现在我可以在我的项目中使用注释了。

© www.soinside.com 2019 - 2024. All rights reserved.