0

Is there any way by which we can set application specific properties within the application? Like server port. Searching solution other than Spring boot and Server.xml. I am using Spring MVC in my web application. Any help is highly appreciated.

Partha.B
  • 51
  • 8
  • My intention is to run multiple applications in a single server and all the application specific properties like server host port will be different. If possible these properties will be set with the help of Spring (Don't want to use Spring Boot). – Partha.B Jan 30 '19 at 11:22

3 Answers3

1

You need to use -D option to specify the explicit configuration parameters if you are executing from command line as follows.

java -Dyour_config_param="value" -jar your_app.jar
ScanQR
  • 3,740
  • 1
  • 13
  • 30
0

Have a look at Spring application properties: https://www.tutorialspoint.com/spring_boot/spring_boot_application_properties.htm.

You can also have multiple properties files for your different environments such as E1, E2 or E3 but appending your properties file name like application-e1.properties and then passing the --Dspring.profiles.active=e1 flag to your application.

Adam
  • 1,724
  • 13
  • 16
0

You can declare property sources in your application.

Here you have a Spring (not Spring Boot) specific blog entry explaining all you need to know about property management:

https://spring.io/blog/2011/02/15/spring-3-1-m1-unified-property-management/

Also, you can check some alternative solutions in this related question:

How to read values from properties file?

Gerardo Roza
  • 2,746
  • 2
  • 24
  • 33