Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to inject string properties containing < character into Spring beans?

Tags:

java

spring

I have following bean definition for my DAO -

<bean id="userDao" class="UserDao">
<property name="dataSource" ref="dataSource" />
<property name="queryPurgeInvalidReferrals" value="delete from reference where date < ?" />
</bean>

I am getting the error - The value of attribute "value" associated with an element type "property" must not contain the '<' character.

like image 618
Monika Michael Avatar asked Apr 16 '12 08:04

Monika Michael


1 Answers

Since Spring config is an XML file, you need to escape < according to XML syntax:

<property name="queryPurgeInvalidReferrals" 
    value="delete from reference where date &lt; ?" /> 
like image 200
axtavt Avatar answered Oct 14 '22 03:10

axtavt