问题描述
我在JAR中打包了许多复合组件。但是,当在另一个项目中使用它们(使用Maven)时,Netbeans编辑器会在使用复合组件的行下放置红色错误行,即使项目按预期编译和运行也是如此。
I have packaged a number of composite components in a JAR. However, when using them in another project (using Maven), Netbeans editor puts red error lines under lines which use the composite component, even though the project compiles and runs as expected.
复合组件JAR的文件夹结构如下所示:
The folder structure for the composite component JAR look like:
compositeComponent.jar
META-INF
faces-config.xml
highcharts-taglib.xml
MANIFEST.MF
web.xml
maven
// maven stuff.
resources
highcharts
Chart.xhtml
Series.xhtml
Tooltip.xml
nz
co
kevindoran
highcharts
example
NZPopulationTrend.class
highcharts.taglib.xml
如下所示:
<facelet-taglib version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd">
<namespace>http://nz.co.kevindoran/highcharts-jsf</namespace>
<composite-library-name>highcharts</composite-library-name>
</facelet-taglib>
[附注:面孔 - 存在config.xml
和 web.xml
,允许通过将文件扩展名更改为WAR来将JAR部署为WAR(这是运行示例)。]
[Side note: The faces-config.xml
and web.xml
are present to allow the 'JAR' to be deployed as a WAR by changing the file extension to WAR (this is to done to run the examples).]
在我当前的项目中,我已经在上面的项目中指定了Maven依赖项,如此:
In my current project, I have specify a Maven dependency on the above project like so:
<dependency>
<groupId>nz.co.kevindoran</groupId>
<artifactId>jsf-menu</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
在JSF页面中,我使用复合组件,如下所示:
In a JSF page, I use on of the composite components like so:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:hc="http://nz.co.kevindoran/highcharts-jsf">
....
<hc:TimeChart title="Price Over Time" xLabel="Date" yLabel="Sold Price (NZD)">
<hc:TimeSeries name="Sold" series="#{cc.attrs.model.priceVsTimeChart.soldSeries}"/>
</hc:TimeChart>
....
</html>
上面的所有行中都出现红色错误行,并显示消息:找不到名称空间的库
Red error lines appear under all lines above, with message: "No library found for namespace http://nz.co.kevindoran/highcharts-jsf"
如何删除这些错误行?我已经看到许多类似问题的Netbeans错误报告,但似乎都解决了。
How do I get these error lines to be removed? I have seen many Netbeans bug reports for similar issues, but all seem resolved.
Netbeans 7.1,7.2和7.3(包括7.3.1)发生此错误。
This error occurs on Netbeans 7.1, 7.2 and 7.3 (including 7.3.1).
推荐答案
我有完全相同的问题。在我的情况下,它取决于/ src / main / java文件夹。如果它存在(仅在项目中,甚至在jar中),则包含此库的项目显示找不到命名空间的库...
当我删除java文件夹时,它可以工作。但是我的支持bean课程在jar中错过了...
I have absolutely the same problem. In my case it depends on the /src/main/java folder. If it's exist (only in the project and not even in the jar) the project which includes this library shows the "No library found for namespace... "When i remove the "java" folder it works. But then my backing bean class is missed in the jar...
尝试使用Netbeans 7.2和7.3,maven 2
Tried with Netbeans 7.2 and 7.3, maven 2
解决方案:
- 生成包含Java源文件的第二个项目。 (调用:jsf-lib-java)
- 在jsf-lib项目(使用xhtml的复合组件项目)中删除java文件夹和所有* .java源。
- 在配置后添加jsf-lib pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.mycompany.project</groupId>
<artifactId>jsf-lib-java</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>src/main/</outputDirectory>
<includes>**/*.class</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
就是这样。这将生成一个带有所需* .class文件的好jar文件。因此有可能欺骗Netbeans。
That's it. This will generate a "good" jar file with the required *.class files. So it's possible to "trick" Netbeans.
现在我使用这个解决方案。这是一个黑客,但没有找到更好的解决方案。
Now i work with this solution. It's a hack but didn't found a better solution.
这篇关于Netbeans中无法识别外部JAR中的复合组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!