将 Java 库添加到 Netbeans Grails 项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/294279/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 11:47:33  来源:igfitidea点击:

Add Java Libraries to a Netbeans Grails Project

javagrailsnetbeansgroovyjar

提问by Buzzy

I am just getting started with Grails. How do I add Java libraries to my Grails project? I added the Smack library jar to the lib folder of my Grails project, but I still cannot import any of its packages into my Java or Groovy classes. I am using the Netbeans IDE. Any help would be appreciated..

我刚刚开始使用 Grails。如何将 Java 库添加到我的 Grails 项目中?我将 Smack 库 jar 添加到我的 Grails 项目的 lib 文件夹中,但我仍然无法将它的任何包导入到我的 Java 或 Groovy 类中。我正在使用 Netbeans IDE。任何帮助,将不胜感激..

Buzzy

嗡嗡声

采纳答案by Buzzy

This is a know bug in NetBeans: http://www.netbeans.org/issues/show_bug.cgi?id=144243

这是 NetBeans 中的一个已知错误:http: //www.netbeans.org/issues/show_bug.cgi?id=144243

Maybe you can help the devolpers to fix it by adding a comment to this issue in the NetBeans bug tracker.

也许您可以通过在 NetBeans 错误跟踪器中为此问题添加注释来帮助开发人员修复它。

回答by simon

Here is what I did to solve the problem when running SpringSource Toolsuite:

以下是我在运行 SpringSource Toolsuite 时为解决问题所做的工作:

  1. Configure the build path by adding external jars (e.g. javax.mail, adwords-api, etc.)

  2. Imported the same jars in to the lib folder (where mysql connector jar is located).

  1. 通过添加外部 jar(例如 javax.mail、adwords-api 等)来配置构建路径

  2. 将相同的 jar 导入 lib 文件夹(mysql 连接器 jar 所在的位置)。

This should fix the compile time errors you would receive from missing imports in your java files.

这应该可以修复您在 java 文件中丢失导入时会收到的编译时错误。

Hope this helps

希望这可以帮助

回答by billjamesdev

As stated above, this is a bug in the IDE, not Grails. Those libraries are available in your code, but the IDE won't do any code completion, etc.

如上所述,这是 IDE 中的错误,而不是 Grails。这些库在您的代码中可用,但 IDE 不会执行任何代码完成等操作。

Note, NetBeans 6.5 is supposed to have much better Grails integration. Or, you could use IntelliJ, which already has it.

请注意,NetBeans 6.5 应该具有更好的 Grails 集成。或者,您可以使用已经拥有它的 IntelliJ。

G2One's acquisition by Spring Source makes the roadmap for Eclipse integration for Grails look much rosier, too. It's not there yet, but it's coming, and now maybe faster than we thought.

G2One 被 Spring Source 收购也使得 Grails 的 Eclipse 集成路线图看起来更加乐观。它还没有出现,但它即将到来,而且现在可能比我们想象的要快。

回答by njebert

The issue still remains in NetBeans 6.5 (Build 200811100001), so the IDE will not do any code completion and formats the code that is referencing classes in the JAR as erroneous.

该问题在 NetBeans 6.5(内部版本 200811100001)中仍然存在,因此 IDE 不会执行任何代码完成并将引用 JAR 中的类的代码格式化为错误的。

I have not tried NetBeans 6.7.

我还没有尝试过 NetBeans 6.7。

回答by njebert

I'm using Netbeans 6.7. I just pasted the library in the project's 'lib' folder and when I went back to Netbeans the library was under the 'Libraries' folder automagically!

我正在使用 Netbeans 6.7。我刚刚将库粘贴到项目的“lib”文件夹中,当我回到 Netbeans 时,该库自动位于“库”文件夹下!

回答by lapinferoce

i m also using netbean 6.7 and it's automagically working when i passed the jar under Libraries folder

我也在使用 netbean 6.7,当我通过库文件夹下的 jar 时它会自动工作