我很难在我的项目上运行 Enunciate。该项目是一个多模块 maven 项目,可从https://svn.opentripplanner.org/trunk获得。我想要的只是 API 文档。没有其他的。我们曾经通过 Maven 和 Hudson 进行这项工作,但它不久前就坏了,并且设置它的人不可用。真的,我更愿意通过命令行界面来做这件事,但如果有人有 Maven 解决方案,我会接受的。
我口齿不清的命令行是:
/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>
我口齿不清的输出是:
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' 就在结束反引号之前),我仍然得到错误的其余部分。不过,解决这些问题也很好。