Like any other file extensions, Comments are allowed specific to related language providers.

comments always start in a new line with space followed by # or ! character and followed by comments text.

java properties files support single-line comments only.

Properties commands do not support following

  • Inline comments are allowed
  • Block comments are not supported Comments format can be represented in two formats

One is using the Semicolon symbol ; placed at the beginning of each line followed by comment text. Another way is to use the hash symbol # for key and value pair comments. hashing syntax only supports some of the implementations and space after the # symbol is recommended.

Important rules

  • Comments must prefix semicolon followed by a space
  • Comments must be single line only and closed

Here is a syntax

# comments text

key= value

Comments text are not processed or interpreted by programming languages

Properties comments example

Let’s see the sample properties file with inline comments declared

\# database to use
database=mysql ;# inline comments

\# Environment of an application
environment=production

Java properties support multi-line comments?

Java properties support single-line comments that start with a newline followed by the # symbol.

Any text that starts with # symbol \ is ignored by the java compiler when reading the properties files.

Does Java properties support inline comments?

Java properties do not support inline comments.

Some languages have support for inline comments in property files

How do you comment on application.properties in the Spring boot application?

Spring boot is a Java application, so We can write single-line comments that start with the # symbol followed by a comment string.

Application.properties

# this is a comment
database=mysql