[英]Java - Adding jar dependency in pom.xml
I have never built my java applications by maven.我从来没有用 Maven 构建过我的 Java 应用程序。 But when i am trying to do that it's giving me error.
但是当我尝试这样做时,它给了我错误。 I have created JAR file from other java application just by exporting as JAR from that application.
我只是通过从该应用程序导出为 JAR 来从其他 Java 应用程序创建 JAR 文件。 Now i want to add this JAR in my maven application.
现在我想在我的 Maven 应用程序中添加这个 JAR。 I don't really how to do that.
我真的不知道该怎么做。
this is how i have added in pom.xml.这就是我在 pom.xml 中添加的方式。 But i don't really know what should be it's artifact id.
但我真的不知道它的工件 ID 应该是什么。 Seriously what is artifact id?
说真的,什么是工件 ID?
<dependency>
<groupId>ProjectZen</groupId>
<artifactId>community</artifactId>
<scope>system</scope>
<version>1</version>
<systemPath>${basedir}\libs\ProjectZen.jar</systemPath>
</dependency>
I am getting below error我得到以下错误
Missing artifact ProjectZen:community:jar:1
Thanks Fahad Mullaji感谢法赫德·穆拉吉
If it is custom jar you need to do following things Open cmd and type following command如果是自定义 jar,则需要执行以下操作 打开 cmd 并键入以下命令
mvn install:install-file -Dfile=path-to-your-artifact-jar \
-DgroupId=ProjectZen
-DartifactId=community
-Dversion=1
-Dpackaging=jar
-DgeneratePom=true
Now, the “ProjectZen” jar is copied to your Maven local repository.现在,“ProjectZen”jar 已复制到您的 Maven 本地存储库。
In pom.xml在 pom.xml 中
<dependency>
<groupId>ProjectZen</groupId>
<artifactId>community</artifactId>
<scope>system</scope>
<version>1</version>
<systemPath>${basedir}\libs\ProjectZen.jar</systemPath>
</dependency>
now the “ProjectZen” jar is able to retrieve from your Maven local repository.现在“ProjectZen”jar 可以从您的 Maven 本地存储库中检索。
change改变
<systemPath>${basedir}\libs\ProjectZen.jar</systemPath>
to到
<systemPath>${basedir}/libs/ProjectZen.jar</systemPath>
you should give the format as below.你应该给出如下格式。 and the slashes used in are incorrect I suppose.
并且我认为中使用的斜杠不正确。 Check the dependency in this format.
检查这种格式的依赖关系。 ...
...
<profiles>
<profile>
<id>default-tools.jar</id>
<activation>
<property>
<name>java.vendor</name>
<value>Sun Microsystems Inc.</value>
</property>
</activation>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.4.2</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</profile>
... ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.