【发布时间】:2017-05-29 12:06:54
【问题描述】:
当我右键单击缺少的导入时,我有一个“在 Web 上查找 Jar”选项,但列表中的 Jar 已过时。例如,列表中最新的 ant jar 是 ant-1.7.1.jar,但我知道 ant-1.10.1.jar 可以从 Maven Central 获得。
如何在 IntelliJ 搜索中添加更多“来源”?
【问题讨论】:
标签: maven intellij-idea dependencies
当我右键单击缺少的导入时,我有一个“在 Web 上查找 Jar”选项,但列表中的 Jar 已过时。例如,列表中最新的 ant jar 是 ant-1.7.1.jar,但我知道 ant-1.10.1.jar 可以从 Maven Central 获得。
如何在 IntelliJ 搜索中添加更多“来源”?
【问题讨论】:
标签: maven intellij-idea dependencies
发生这种情况是因为您的 IntelliJ 中的存储库已过时,因此,您可以使用以下步骤进行更新,请转到:
Preferences > Build, Execution, Deployment > Maven > Repositories
选择Remote 存储库条目并单击Update 按钮,此操作需要几分钟,之后,对您的Local 存储库执行相同操作,IntelliJ 将能够检索您的依赖项的最新版本.
更新
要在 IntelliJ 中查看远程存储库,您可以添加 settings.xml 文件 (check this) 或直接添加到项目的 pom.xml 文件中。
这是您的settings.xml 文件的结构:
<project>
<repositories>
<repository>
<id>maven-central</id>
<url>http://repo.maven.apache.org/maven2</url>
</repository>
</repositories>
</project>
这是pom.xml 文件的结构:
<dependencies>
...
</dependencies>
<repositories>
<repository>
<id>codehausSnapshots</id>
<name>Codehaus Snapshots</name>
<releases>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http://repo.maven.apache.org/maven2</url>
<layout>default</layout>
</repository>
</repositories>
添加此配置后,IntelliJ 将能够检测到新的存储库。
注意:在你的 pom.xml 文件中指定的更新(或继承自父项目的 pom 和 settings.xml)
【讨论】:
No remote repositories,但在另一个项目中,我看到了您发布的 URL。如何添加 Maven 存储库?
File > Settings... > Build, Execution, Deployment > Remote Jar Repositories。