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:
- Ensure that all necessary dependencies are already downloaded into the local Maven repository (
~/.m2/repository). - Run Maven with the
-oor--offlineparameter 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.