简体   繁体   English

如何让 Netbeans 6.5 可共享库工作

[英]How to get Netbeans 6.5 shareable libraries working

I created a Web application in Netbeans 6.5.我在 Netbeans 6.5 中创建了一个 Web 应用程序。 Now I want to use the Joda Time library.现在我想使用 Joda Time 库。 I want to share this library via subversion, because I don't want my team mates to be dependend on some Netbeans configuration.我想通过 subversion 共享这个库,因为我不希望我的队友依赖一些 Netbeans 配置。

Just to get the project working, I first added the library to the Netbeans library (Tools->Library).为了让项目正常运行,我首先将该库添加到 Netbeans 库(工具->库)中。 This worked OK.这工作正常。 The JAR is added to the classpath, and is also deployed. JAR 已添加到类路径中,并且也已部署。

But when I create a shared library (via Project Properties->Libraries->Browse/New Libraries Folder), the JAR is not in the classpath.但是当我创建一个共享库(通过项目属性->库->浏览/新建库文件夹)时,JAR 不在类路径中。 I get the error message package org.joda.time does not exist on the code import org.joda.time.* .我收到错误消息package org.joda.time does not exist on the code import org.joda.time.*

Any ideas?有任何想法吗?

What is the scope of this library?这个库的 scope 是什么? Is this library used for just this particular web-application?这个库是否仅用于这个特定的 Web 应用程序?

If so, can we put the library in the WEB-INF/lib directory and check that into subversion as well?如果是这样,我们可以将库放在 WEB-INF/lib 目录中并将其也检查到 subversion 中吗?

Libraries in the WEB-INF/lib directory should be automatically added to the classpath of the project. WEB-INF/lib 目录中的库应该自动添加到项目的类路径中。

Here is what I did:这是我所做的:

  • Tools -> Library -> New Library...工具 -> 库 -> 新库...

    • called the library joda-time叫图书馆joda-time
    • add added the joda-time-1.6.jar file to it添加 joda-time-1.6.jar 文件到它
  • Project -> Properties -> Libraries项目 -> 属性 -> 库

    • under the compile tab在编译选项卡下
      • Add library...添加库...
      • selected joda-time选定的乔达时间

(Edit, think I see the issue now - but perhaps not). (编辑,我想我现在看到了这个问题——但也许没有)。

You need to add the library to the compile libraries AND add it to the distribution libraries.您需要将库添加到编译库并将其添加到分发库。 Or am I misunderstanding the question?还是我误解了这个问题?

This blog entry describes a hack that worked in NetBeans 5. I don't know if it will work in NetBeans 6.5.这篇博客文章描述了一个在 NetBeans 5 中工作的 hack。我不知道它是否能在 NetBeans 6.5 中工作。 I also don't know if this will work if you are building files nightly on a server.如果您每晚在服务器上构建文件,我也不知道这是否可行。

http://blogs.oracle.com/gjmurphy/entry/using_netbeans_free-form_projects_as http://blogs.oracle.com/gjmurphy/entry/using_netbeans_free-form_projects_as

I remember setting up shared libraries like this 8 years ago in JBuilder.我记得 8 年前在 JBuilder 中设置了这样的共享库。 I wish Netbeans had it by now.我希望 Netbeans 现在拥有它。

when creating a 'new project', there is an option to enable 'dedicated folder for libraries'.创建“新项目”时,可以选择启用“库专用文件夹”。 That way, the libraries will also be committed to the repository and your peer developer can checkout your project with all the libraries, your project has dependencies upon, thereby eliminating netbeans configuration bound.这样,库也将提交到存储库,您的同行开发人员可以使用所有库签出您的项目,您的项目具有依赖关系,从而消除 netbeans 配置绑定。

In scenario where a project depends on JARs which can be placed in different locations for different users, a named IDE variable can be used.在项目依赖于 JARs 的情况下,可以为不同的用户放置在不同的位置,可以使用名为 IDE 的变量。

http://wiki.netbeans.org/NewAndNoteWorthyNB65#section-NewAndNoteWorthyNB65-VariableBasedPathsInJ2SEJ2EEProjects http://wiki.netbeans.org/NewAndNoteWorthyNB65#section-NewAndNoteWorthyNB65-VariableBasedPathsInJ2SEJ2EEProjects

Another option would be to use the Maven plugin which already works quite well in NetBeans 6.5.另一种选择是使用 Maven 插件,该插件在 NetBeans 6.5 中已经运行良好。 A Intranet repository for the Artifact Jar files could be placed on a file server, or managed through a Maven Proxy like Nexus. Artifact Jar 文件的 Intranet 存储库可以放置在文件服务器上,或通过 Maven 代理(如 Nexus)进行管理。

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

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