java properties file using multiple lines for one property

java, properties, spring

Solution

Use \ at the end of the line like

  someSQL = select result \
              from myTable \
              where y = 2  \
              and x = ? \
              order by z

Also, beware of any trailing whitespaces since Java looks for consecutive backslash+linebreak when assembling the lines.

Put differently : The backslash has to be the very last caracter on the line before the line break.

Problem

I am storing sql in a properties file and injecting it using spring this works : ``` someSQL = select result from myTable where y = 2 and x = ? order by z ``` but for readibility I want this : ``` someSQL = select result from myTable where y = 2 and x = ? order by z ``` What is the correct text formatting I need to use ?

Original source