与外部jar包maven项目

时间:2017-11-08 03:07:53

标签: maven

我在我的maven项目中使用了外部jar:

的pom.xml

enter image description here

但是当我打包项目时:

由IDEA打包

enter image description here

失败了:

失败日志

enter image description here

我想知道在maven存储库中找不到jar时如何解决这个问题。

2 个答案:

答案 0 :(得分:1)

也许您应该在依赖语句中使用maven存储库的直接链接?例如,在这里:

<!-- https://mvnrepository.com/artifact/net.sf.json-lib/json-lib -->
<dependency>
    <groupId>net.sf.json-lib</groupId>
    <artifactId>json-lib</artifactId>
    <version>2.4</version>
</dependency>

答案 1 :(得分:1)

您正在尝试为依赖项定义systemPath,但只允许使用 system scope的依赖项。你必须:

  • 删除systemPath并使用(或配置)将从中下载依赖项的Maven存储库。如果您使用开源或公共依赖项,则默认情况下它们可能会在Central Maven repository上可用。
  • 为依赖项定义系统范围,例如:

<dependency>
    <groupId>com.someproject.foo</groupId>
    <artifactId>foo-lib</artifactId>
    <version>1.2.3/version>
    <scope>system</scope>
    <systemPath>...</systemPath>
</dependency>

如果您的依赖项是私有的或公司所有,我强烈建议您为您和您的团队配置Maven仓库,而不是使用系统依赖性。 Using system scope is deprecated

  

系统依赖

     

重要提示:这已标记为已弃用。