Anurag Tiwari
Anurag Tiwari

Reputation: 21

What is use of -D in spring framework?

-Dspring where property file can read with like -Dspring.tenantid and -Dtenantid

Upvotes: 0

Views: 592

Answers (3)

A G
A G

Reputation: 307

The -D is not a Spring thing. It is a Java command-line thing. -D is used to pass System Property key and value.

You can either choose to pass it over the command line or read from a property file and set it to System properties.

Spring uses System properties with a configurable prefix to ease configuration of connection parameters like Database or JMS.

Hope this helps. :)

Upvotes: 2

Hemant
Hemant

Reputation: 1438

-D is one of java command options and Sets a system property value.

java -Dmydir="some string" SomeClass

Reference here: https://docs.oracle.com/javase/7/docs/technotes/tools/windows/java.html

In sprinboot applications we use this to set properties in environment.

If the same property exist in properties files then property passed through -D will take precedence.

Reference - https://www.baeldung.com/properties-with-spring

Upvotes: 2

Aditya Rewari
Aditya Rewari

Reputation: 2707

-D is a marker sort of, any variable you want to declare/overwrite

Any key-value you want to declare will start with this.

Upvotes: 1

Related Questions