0

I am running a Java Spring application on weblogic server. This application uses a config property which is not defined in code but should be passed as an argument. Value for this property should be passed as Argument when the application starts.

But the application has to run on weblogic server. How can the property be set for the application while running on weblogic server?

Thanks for the help.

Bharath Reddy
  • 301
  • 2
  • 4
  • 15
  • I think [this post](https://stackoverflow.com/questions/43975472/accesing-spring-boots-application-properties-on-weblogic-10-3-6) can help you. – juanlumn Sep 14 '17 at 16:49

2 Answers2

1

You can pass your config property as part of JVM property

 -DMyArg=MyValue

and in your code write following code to access the value

 value=System.getproperty("MyArg"); 
Ravi
  • 30,829
  • 42
  • 119
  • 173
0

Assuming you have set the system property correctly in Weblogic then you can use the Spring @Value annotation:

public class SomeClass{

    @Value("${some.property.name}")
    public String someProperty;

}

Properties can be resolved form various places, including system properties.

https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html

Alan Hay
  • 22,665
  • 4
  • 56
  • 110