Using IntelliJ Path Variables, how to set system properties in a Tomcat server. Run the configuration?

In Eclipse, you can set the -D options to include the {} variables that were defined elsewhere in the IDE settings. IntelliJ seems to provide this function with Path variables. However, if you follow their help docs, you should be able to reference these variables between $ dollar_characters $. Further research would show that this applies only to the internal files of the project, and the replacement is performed during assembly.

I am trying to create a configuration with a shared server, where some properties of the system can be replaced by other developers, but it puzzles me a lot.

+6
source share
3 answers

After long jerks and studies of seemingly unrelated problems, I began to get a more detailed picture of how to do this:

  • Set path variables as needed.
  • Create your launch configuration that you plan to use and check the Share box.
  • Paste into the stubs (ie -Dsystem.property="variable here" ) in the VM options box of your configuration.
  • Find your configuration in .idea/runConfigurations and replace the stubs with $PATH_VARIABLE$ , placing them inside quotation marks if the value contains spaces.
  • Open the “Change Configuration” screen for your launch configuration and note that the variable extension succeeded. Even better, check it and ask a colleague to check it (after setting your own path variables) and note that the variable extension works with its custom values.

Note. . It may seem that you can place those $PATH_VARIABLES$ directly in these configuration screens, but this only works if you edited the XML files directly.

+5
source

You can directly configure the parameters of the virtual machine in the Tomcat server startup / debug configuration window by adding them to the VM parameters input field. You can directly put in your -Dcustom_property=value in this field, and then access it through System.getProperty("customer_property") .

+9
source

Joel Wilson, thanks for your research on using $ PATH_VARIABLES $ in IntelliJ Configurations.

Embellish your presence a bit; I found out that if the configuration file changes on the file system, it will be restarted by IJ right away ($ PATH_VARIABLES $ get expand). However, if you make changes to the IJ settings, this is not the case.

But if you: tap ~ / IntelliJ / yourProject / .idea / runConfigurations * .xml

This is enough to reload your configurations.
I also found out that if you close and reopen IJ, they will also be automatically expanded.

And if you look at these .xml files, extended values ​​will never be saved. Extension occurs when loading IJ or changing files.

The bottom line, if you want to exchange common configurations in the repo, and then configure the user variable in IJ PATH variables, you can, and they will be automatically expanded.

If you have to change PATH variables, the new values ​​will contain the changed contents of PATH_VARIABLE.

If you look at the files at the OS level, you will see that the variables are saved. But if you look in the configuration editor, the replaced values ​​will always be displayed there (therefore you cannot directly see that they used the variable). It is best to look at the OS file for this. Jim

+2
source

All Articles