XmlJavaTypeAdapter 并阐明?

发布于 2024-11-17 17:50:45 字数 2523 浏览 3 评论 0原文

我在我的项目上运行 Enunciate 时遇到了困难。该项目是一个多模块 Maven 项目,可从 https://svn.opentripplanner.org/trunk 获取。我想要的只是 API 文档。没有别的了。我们曾经通过 Maven 和 Hudson 来实现此功能,但不久前它就坏了,而且设置它的人也不在。确实,我更喜欢通过命令行界面来完成此操作,但如果有人有 Maven 解决方案,我会接受。

我的 enunciate 命令行是:

/home/novalis/otp/enunciate-1.23/bin/enunciate -v -f /home/novalis/otp/workspace/opentripplanner/opentripplanner-api-webapp/enunciate.xml `find /home/novalis/otp/workspace/opentripplanner/ -name *.java -type f |grep -v /test/`

我的 enunciate.xml 看起来像这样:

<enunciate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.17.xsd"> 
  <services> 
    <rest> 
      <content-types> 
        <content-type type="text/plain" id="txt"/> 
      </content-types> 
    </rest> 
  </services> 
  <modules> 
    <c disabled="true"/> 
    <obj-c disabled="true"/> 
    <csharp disabled="true"/> 
    <jaxws-client disabled="true"/> 
    <docs title="OpenTripPlanner API"
          base="src/main/resources/docs-theme"/>
  </modules> 
</enunciate> 

我的 enunciate 输出是:

initializing enunciate.
invoking enunciate:generate step...
error: Could not create declaration for annotation type Autowire
error: Could not create declaration for annotation type Component
error: Could not create declaration for annotation type Autowired
error: Could not create declaration for annotation type Required
4 errors
Exception in thread "main" org.codehaus.enunciate.contract.validation.ValidationException: /home/novalis/otp/workspace/opentripplanner/opentripplanner-routing/src/main/java/org/opentripplanner/routing/patch/StopNotePatch.java:58: stop: adapter org.opentripplanner.routing.patch.AgencyAndIdAdapter does not adapt AgencyAndId
    at org.codehaus.enunciate.contract.jaxb.adapters.AdapterUtil.findAdapterType(AdapterUtil.java:134)
    at org.codehaus.enunciate.contract.jaxb.adapters.AdapterUtil.findAdapterType(AdapterUtil.java:57)
[more traceback snipped]

AgencyAndIdAdapter 确实 适应 AgencyAndId。当我运行它时,实际代码工作得很好。我尝试使用 XmlAdapter 构建一个小型测试用例来适应随机 Java 类(JPanel),并且它工作得很好。所以我不知道如何进一步减少问题。

我不认为有关 Autowire/Component/etc 的错误导致了这种情况,因为如果我排除包含这些注释的所有文件(|xargs grep -L 'Autowire|Component|Request' 就在结束反引号之前),我仍然得到错误的其余部分。不过,解决这些问题也很好。

I'm having a hard time running Enunciate on my project. The project is a multi-module maven project, available from https://svn.opentripplanner.org/trunk . All I want out of enunciate is API docs. Nothing else. We used to have this working via Maven and Hudson, but it broke a while ago, and the person who set it up isn't available. Really, I would prefer to do this via the command-line interface, but if someone has a Maven solution, I'll take it.

My enunciate command-line is:

/home/novalis/otp/enunciate-1.23/bin/enunciate -v -f /home/novalis/otp/workspace/opentripplanner/opentripplanner-api-webapp/enunciate.xml `find /home/novalis/otp/workspace/opentripplanner/ -name *.java -type f |grep -v /test/`

My enunciate.xml looks like this:

<enunciate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.17.xsd"> 
  <services> 
    <rest> 
      <content-types> 
        <content-type type="text/plain" id="txt"/> 
      </content-types> 
    </rest> 
  </services> 
  <modules> 
    <c disabled="true"/> 
    <obj-c disabled="true"/> 
    <csharp disabled="true"/> 
    <jaxws-client disabled="true"/> 
    <docs title="OpenTripPlanner API"
          base="src/main/resources/docs-theme"/>
  </modules> 
</enunciate> 

And my enunciate output is:

initializing enunciate.
invoking enunciate:generate step...
error: Could not create declaration for annotation type Autowire
error: Could not create declaration for annotation type Component
error: Could not create declaration for annotation type Autowired
error: Could not create declaration for annotation type Required
4 errors
Exception in thread "main" org.codehaus.enunciate.contract.validation.ValidationException: /home/novalis/otp/workspace/opentripplanner/opentripplanner-routing/src/main/java/org/opentripplanner/routing/patch/StopNotePatch.java:58: stop: adapter org.opentripplanner.routing.patch.AgencyAndIdAdapter does not adapt AgencyAndId
    at org.codehaus.enunciate.contract.jaxb.adapters.AdapterUtil.findAdapterType(AdapterUtil.java:134)
    at org.codehaus.enunciate.contract.jaxb.adapters.AdapterUtil.findAdapterType(AdapterUtil.java:57)
[more traceback snipped]

AgencyAndIdAdapter does adapt AgencyAndId. The actual code works just fine when I run it. I've tried building a tiny test case with XmlAdapter adapting a random Java class (JPanel), and it works fine. So I can't figure out how to reduce the problem further.

I don't think the errors about Autowire/Component/etc are causing this, because if I exclude all files that contain those annotations (|xargs grep -L 'Autowire|Component|Request' just before the closing backtick), I still get the remainder of the error. Still, it would be good to fix those, too.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文