英文:
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
库:
- 在左侧的
项目
面板中,右键单击模块,然后选择打开模块设置
- 在
项目设置
下选择库
- 在库区域顶部点击
+
符号,然后选择从Maven...
- 输入
org.jetbrains:annotations
,并点击末尾的搜索图标。然后等待下拉菜单列出可用版本。 - 选择您需要的最新或适当的版本,同时启用
下载到:
选项。 - 然后,点击
确定
,完成操作。
英文:
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:
- Right click on the module in the
Project
panel on your left hand side, and select theOpen module settings
- Select
Libraries
underProject settings
- Click the
+
symbol on the top of the library area and select theFrom Maven...
- 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. - Select the latest or appropriate version you need and also enable the
Download to:
option. - 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 :
<!-- 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
得分: 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 'org.jetbrains:annotations:16.0.2'
答案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 <component>
tags.
<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>
Now I can use the annotations in my project.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论