java属性文件,为一个属性使用多行 [英] java properties file using multiple lines for one property

查看:122
本文介绍了java属性文件,为一个属性使用多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将sql存储在一个属性文件中并使用spring注入它可以工作:

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 ?

推荐答案

在行尾使用\,如

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

此外,请注意自Java查找连续以来的任何尾随空格组装线条时反斜杠+换行符。

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.

这篇关于java属性文件,为一个属性使用多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆