简体   繁体   English

单独的JAR文件中的JavaBeans类

[英]JavaBeans Classes in Separate JAR Files

Is it possible to build classes for a JavaBean in separate JAR files? 是否可以在单独的JAR文件中为JavaBean构建类? Specifically- a JavaBean has the Bean and BeanInfo classes in one JAR file and the Custom Property Editor class inn a different JAR, the JAR file with the Bean and BeanInfo classes has the JAR file with the Custom Property Editor class on the classpath, but during drag and drop of the JavaBean in an IDE, a class not found exception is thrown for the Custom Property Editor class. 具体来说-JavaBean在一个JAR文件中具有Bean和BeanInfo类,而在不同的JAR中具有Custom Property Editor类,具有Bean和BeanInfo类的JAR文件在类路径中具有具有Custom Property Editor类的JAR文件。在IDE中拖放JavaBean时,“定制属性编辑器”类将引发“未找到类”异常。 Are all classes for a given JavaBean required to be built into the same JAR file? 是否需要将给定JavaBean的所有类都构建到同一JAR文件中?

The PropertyEditorManager looks for the property editor (JavaBean spec): PropertyEditorManager查找属性编辑器(JavaBean规范):

  1. by looking if an editor has been registered explicitly. 通过查看编辑器是否已显式注册。 Since you are using drag and drop I suppose this is not a good solution for you. 由于您正在使用拖放功能,因此我认为这对您来说不是一个好的解决方案。
  2. looking for 'package.BlahEditor' where 'package.Blah' is your JavaBean. 寻找“ package.BlahEditor”,其中“ package.Blah”是您的JavaBean。 So the names have to be correct for the IDE to find the editor. 因此,名称必须正确,IDE才能找到编辑器。
  3. looking for BlahEditor in a searchlist defined by the container. 在容器定义的搜索列表中寻找BlahEditor。 Again, since you are using drag and drop this is not a solution. 同样,由于您正在使用拖放操作,因此这不是解决方案。

I don't think that there is a problem using different jars, or packaging the editor in a separate jar. 我认为使用不同的jar或将编辑器包装在单独的jar中都没有问题。

I do not have enough information to give a conclusive but I can only suggest to check the naming conventions of your property editor against the name of your JavaBean. 我没有足够的信息来得出结论,但是我只能建议对照JavaBean的名称检查属性编辑器的命名约定。

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

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