当我尝试使用 Maven 通过 Maven 构建项目时,我在 IntelliJ 中遇到了问题
mvn clean install
我尝试了不同的方法,例如更改 JDK 的路径,但没有任何效果。有人可以帮我解决这个问题吗?
如果有人在 IntelliJ IDEA 中使用普通的
Kotlin
项目(没有任何构建工具,如 maven 或 gradle),那么您可以按照以下步骤添加 jetbrain 的 jetbrains.annotations
库:
Project
面板中的模块,然后选择 Open module settings
Libraries
下的
Project settings
+
符号,然后选择 From Maven...
org.jetbrains:annotations
,然后点击其末尾的搜索图标。然后,等待下拉列表列出其可用版本。Download to:
选项。OK
即可完成。如果您确实需要它们,请在 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)
对我来说,添加
jetbrains
依赖关系效果很好。
提供类似这样的依赖。
对于 Gradle:
implementation 'org.jetbrains:annotations:16.0.2'
只需将此代码放入构建 gradle 中即可运行。
实现“org.jetbrains:annotations:16.0.2”
我遇到了同样的问题,来到这里寻找解决方案,但我找不到前面提到的 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>
现在我可以在我的项目中使用注释了。