How to pass value to maven pom.xml at rum time from java file?

后端 未结 1 1234
野性不改
野性不改 2020-12-12 06:40

I have a java file where a variable taken value at run time.I search for a service using web service discovery and keep its url in a variable. Now I need to pass this value

相关标签:
1条回答
  • 2020-12-12 07:37

    I don't consider this as an Apache Maven specific issue, but a general Java issue (Maven probably made you aware of it). During build-time you have no idea what the url should be. Depending on the type of application you have several options:

    • JNDI (in case of a webcontainer)
    • A properties file on a predefined location
    • System properties
    • As arguments (in case of executable jar)
    • Adjust web.xml before deploying (some webcontainers can help you with this)
    • ...

    In you use a framework like Spring there are easy ways to inject one the options above.

    0 讨论(0)
提交回复
热议问题