开发者

Can we have multiline comments in a Java properties file?

开发者 https://www.devze.com 2023-01-24 09:07 出处:网络
In a Java .properties file we can do single line comments with #. Is there any way by which we can do multi-line comments?开发者_开发百科Unfortunately not!Java properties file only have single line #

In a Java .properties file we can do single line comments with #.

Is there any way by which we can do multi-line comments?开发者_开发百科


Unfortunately not! Java properties file only have single line # comments.


If you use Eclipse, you can select multiple lines and comment all with a shortcut (Ctrl+/ by default). Same shortcut uncomments the lines, but you have to pay attention no to select any empty line, which will cause the non-empty ones to get commented more than once.

These apply to Eclipse, but I guess many IDE:s and some editors offer similar functionality.


.properties files do not have multiline comments.

Since JDK 1.5 Properties have XML support, and XML format supports multiline comments. See javadocs.


I have made a class that handles comments in properties. Both general header comments and comments for individual properties.

Have a look at : CommentedProperties JavaDoc

The jar file can be downloaded here : Download jar file from sourceforge


We can use Ctrl+/ to comment multiple lines in properties file. But it will put # for blank line also.


Select the content to comment out and press ctrl+/ on the eclipse editor


Java properties file only have single line (#) comments. If you have to comments in the multiple lines then you have to use # symbol at the beginning line of the code.


If you are using Eclipse there is this shortcut Ctrl+Shift+A that turns on selecting a column, so you can just drag through all the rows you need to comment and add # (this will add it to all rows). It will be the same when you want to delete the #. To turn off the column selecting mode you have to again press Ctrl+Shift+A.


We can use Ctrl+/ to comment multiple lines in properties file.


As I know, in file application.properties can only use tag '#' to comment.


Yes you can comment multiline in java properties file by using shortcut key Ctrl+/.


In application.properties of spring boot application you can use cltr+/ to add multiple-line comments.


single line comment using #

multiline comment using <!-- -->

0

精彩评论

暂无评论...
验证码 换一张
取 消