Sobes.tech
Junior — Middle

How can Maven be configured to work offline without an internet connection?

sobes.tech AI

Answer from AI

To configure Maven in offline mode:

  1. Ensure that all necessary dependencies are already downloaded into the local Maven repository (~/.m2/repository).
  2. Run Maven with the -o or --offline parameter to prevent attempts to connect to remote repositories.

Example command:

mvn clean install -o

If some artifacts are not available locally, Maven will report an error. Therefore, it is recommended to perform a build in online mode first to download all dependencies.

You can also configure the settings.xml file, specifying mirrors and repositories, but the key point is to use the -o flag for offline mode.