0

我的 Java 文档中有以下段落:

 * <pre>
 * {@code
 * <?xml version="1.0" encoding="UTF-8"?>
 * <beans xmlns="http://www.springframework.org/schema/beans"
 *  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 *  xmlns:context="http://www.springframework.org/schema/context"
 *  xmlns:task="http://www.springframework.org/schema/task"
 *  xmlns:tx="http://www.springframework.org/schema/tx"
 *  xsi:schemaLocation="http://www.springframework.org/schema/beans 
 *             http://www.springframework.org/schema/beans/spring-beans.xsd
 *             http://www.springframework.org/schema/context
 *      http://www.springframework.org/schema/context/spring-context.xsd
 *      http://www.springframework.org/schema/tx  http://www.springframework.org/schema/tx/spring-tx.xsd
 *      http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">
 * 
 *  <bean class="path.to.job.Class"
 *      id="jobBeanName" parent="baseJob">
 *      <!-- PROPERTIES OMITTED -->
 *  </bean>
 * 
 *  <task:scheduled-tasks scheduler="scheduler">
 *      <task:scheduled ref="jobBeanName" method="execute"
 *          cron="${cron_expression}" />
 *  </task:scheduled-tasks>
 * 
 * </beans>
 * }
 * </pre>

这部分应该说明如何完成新定义的快速指南。然而,由于某种原因,“翻译”并不完整。

这就是它的结果:

 <?xml version="1.0" encoding="UTF-8"?>
 <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:task="http://www.springframework.org/schema/task"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
               http://www.springframework.org/schema/beans/spring-beans.xsd
               http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/tx  http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">

    <bean class="path.to.job.Class"
        id="jobBeanName" parent="baseJob">
        <!-- PROPERTIES OMITTED -->
    </bean>

    <task:scheduled-tasks scheduler="scheduler">
        <task:scheduled ref="jobBeanName" method="execute"
            cron="${cron_expression}" />



 }

它缺少这些部分:

    </task:scheduled-tasks>
</beans>

并包括}哪个是{@code }.

使它们可见的唯一方法是<在两个元素之后添加一个空格。虽然这个空间在文档中也是可见的,这使得它非常难看。


我检查了以下链接:


实际上我只是找到了一种方法来替换<&lt;显示的部分。尽管这并不能解释为什么它有时会起作用,有时却不起作用。另外,我仍然有显示}的部分的片段(){@code }

所以问题是,如何在 JAVADOC 中格式化 XML,而不需要像“hacks”一样&lt;并且有不应该显示的片段?

4

0 回答 0