org.xml.sax.SAXParseException; lineNumber: 64; columnNumber: 14; cvc-complex-type.2.3: Element ‘bean’ cannot have character [children], because the type’s content type is element-only.
0.背景
wildfly部署war包的时候报这个错,这个错误指向了当时配置shiro反序列化漏洞时添加了一行代码:
<property name="cipherKey" value="#{T(com.xxx.xxx.shiro.GenerateCipherKey).generateNewKey()}"/>
这个代码是正常引用,想了很长时间没有想明白。后来终于不断尝试找到了疑似正确解法,才发现我犯了基础(愚蠢)的错误。
原来xml文件是这么写的
<bean id="remembermeManager" class="org.apache.shiro.web.mgt.CookieRememberMeManager">
<property name="cookie" ref="remembermeCookie"/>
<property name="cipherKey" value="#{T(com.xxxx.xxx.shiro.GenerateCipherKey).generateNewKey()}"/>
</bean>
然后改成下面这样:
<bean id="remembermeManager" class="org.apache.shiro.web.mgt.CookieRememberMeManager">
<property name="cipherKey" value="#{T(com.xxxx.xxx.shiro.GenerateCipherKey).generateNewKey()}"/>
<property name="cookie" ref="remembermeCookie"/>
</bean>
可以看出,只是换了顺序,就正常了。