属性"值"的值与元素类型相关联"属性"不得包含'<'字符

时间:2016-12-11 18:22:32

标签: spring spring-batch

<bean id="fileDiffTaskelt" class="org.springframework.batch.core.step.tasklet.SystemCommandTasklet" scope="step">
<property name="command" value="diff #{jobParameters['INPUT_FILE']} #{jobParameters['PREVIOUS_FILE']} |  grep -e '<' -e '>' | grep -x '.\{20\}' > #{jobParameters['FILTERED_FILE']}"/>
<property name="timeout" value="60000"/>
<property name="workingDirectory" value="/tmp/hub"/>
</bean>

我在IDE中收到此错误:属性&#34;值&#34;与元素类型相关联&#34;属性&#34;不得包含&#39;&lt;&#39;字符。我在我的grep命令中使用这个字符非常重要,卡在这里。

1 个答案:

答案 0 :(得分:4)

您可以Escape Strings使用相同的内容。

将值属性中的'<'替换为&apos;&lt;&apos;

    <property name="command" value="diff #{jobParameters['INPUT_FILE']}
      #{jobParameters['PREVIOUS_FILE']} |  grep -e &apos;&lt;&apos; -e &apos;&gt;&apos; 
      | grep -x '.\{20\}' > #{jobParameters['FILTERED_FILE']}"/>

同样适用于escape strings

的适当'>'

XML Escape Strings