Fix IntelliJ not recognizing path variable

Updated at 1708008690000

Description

IntelliJ, especially on Windows, may have an issue recognizing path variables, preventing us from building the program. Let's assume we need to import an environment variable EZYPLATFORM_HOME like this: <ezyplatform.home>${env.EZYPLATFORM_HOME}</ezyplatform.home>, pointing to the /{your_path}/ezyplatform directory, example: /App/ezyplatform .

Steps

Step 1. Create Environment Variable

  1. Use Google to search: add environment variable corresponding to your operating system to create the variable EZYPLATFORM_HOME=/App/ezyplatform, you can refer to: Add Environment Variables.
  2. Return to the project and try to build. If it works, you are done; otherwise, proceed to step 2.

Step 2. Create Environment Variable in IntelliJ

  1. Open IntelliJ settings, navigate to Path Variables, and add the variable EZYPLATFORM_HOME, for example:
step1.png
  1. Return to the project and try to build. If it works, you are done; otherwise, proceed to step 3.

Step 3. Add Global VM Options for Maven

  1. Open IntelliJ settings, go to Importing, and add the following to VM options for the importer:
  • Denv.EZYPLATFORM_HOME=/App/ezyplatform

```

For example:

step2.png
  1. Also, in Maven settings, go to Runner, and add VM Options:

```

  • Denv.EZYPLATFORM_HOME=/App/ezyplatform

```

And add Environment variables: `EZYPLATFORM_HOME=/App/ezyplatform`

For example:

step3.png
  1. Return to the project and try to build. If it works, you are done; otherwise, proceed to step 4.

Step 4. Configure on Project Level

  1. Create a project configuration and add VM Options:

```

  • Denv.EZYPLATFORM_HOME=/App/ezyplatform

```

And add Environment variables: `EZYPLATFORM_HOME=/App/ezyplatform`

For example:

step4.png
  1. At the same time, in the configuration of the startup class (containing the main method) of the program, you will also need to add VM Options and Environment variables similarly, for example:
step5.png
  1. Return to the project and try to build. If it works, you are done; otherwise, further investigation is needed.