Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
548 views
in Technique[技术] by (71.8m points)

Adding external JAR to Maven project in NetBeans

When I right click on my Maven project and choose the Add dependency option and I type my external jar's name in query, it is not found. How to add external jar to a Maven project?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

From the NetBeans forum:

  1. Open the Projects tab.
  2. Right-click on Dependencies.
  3. Select Add dependency.
  4. Set groupId to: group.id (can be anything)
  5. Set artifactId to: artifact.id (can be anything)
  6. Set version to: 1.0 (can be anything)
  7. Click Add to continue.

Dependency is added to pom.xml and appears under the Libraries node of Maven project. Continue:

  1. Expand Dependencies.
  2. Right-click on library (e.g., group.id).
  3. Select Manually install artifact.
  4. Set Artifact to install with the Java Archive (.jar) file path.
  5. Click Install locally.

Library is installed locally with dependency attributes (coordinates) entered in steps 4 - 6.


I found those instructions helpful when going through the NetBeans GUI. Basically when right clicking to add a dependency, the group id, version, and name must be populated with anything. Then that "dependency" will be listed in the dependency drop down. Right click on that newly created dependency and right click to install locally and navigate to the appropriate jar file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...