简体   繁体   English

NetBeans:如何从Maven repo中为非maven项目添加库

[英]NetBeans: How to add library from Maven repo for non-maven project

For a plain "Java application" project, how can I add a dependency or library from Maven? 对于简单的“Java应用程序”项目,如何从Maven添加依赖项或库? If I right click on "Libraries" in the projects pane, it only allows me to add local libraries. 如果我右键单击项目窗格中的“库”,它只允许我添加本地库。 But if my project is a Maven Java Application, then there's the "Dependencies" node in the projects pane, and from there I can right click and choose "Add dependency...". 但是如果我的项目是Maven Java Application,那么项目窗格中就有“Dependencies”节点,从那里我可以右键单击并选择“Add dependency ...”。

I'm using NetBeans 8.0. 我正在使用NetBeans 8.0。

You can either download the library manually eg from http://search.maven.org (don't forget the transitive dependencies as well!). 您可以手动下载库,例如从http://search.maven.org下载(也不要忘记传递依赖项!)。 Or if you're using Ant (the default project type in NetBeans): consider to use Ant Ivy to manage your dependencies. 或者,如果您正在使用Ant(NetBeans中的默认项目类型):请考虑使用Ant Ivy来管理您的依赖项。

You need to build a Maven style project before NetBeans can use its built in Maven plugin - to help you with dependencies. 在NetBeans使用其内置的Maven插件之前,您需要构建Maven样式项目 - 以帮助您进行依赖。

See http://maven.apache.org/ http://maven.apache.org/

Install Maven per the instructions exactly. 按照说明准确安装Maven。 Then you can generate a new Maven style project on the command line with 然后,您可以在命令行上生成一个新的Maven样式项目

mvn archetype:generate

and import the generated project into NetBeans. 并将生成的项目导入NetBeans。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM