软件包org.jetbrains.annotations不存在

问题描述

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

<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>

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

解决方法

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

,

我遇到了同样的问题,来到这里寻找解决方案,但我找不到前面提到的 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>

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

,

对我来说,添加 jetbrains 依赖项效果很好。

提供类似这样的依赖项。

对于 Gradle:

implementation 'org.jetbrains:annotations:16.0.2'
,

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

实现'org.jetbrains:annotations:16.0.2'