2

I have created a web application in spring mvc and now i have to migrate the project to an offline machine but when i imported the project in my eclipse(offline) then it got stuck on "Importing Maven Projects" and also it is showing an error in my pom.xml file at tag :-

    <plugins>
     <plugin> // shows error over here
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>

I also read something about mvn dependency:go-offline so I tried it but couldn't exactly understand that where it saves the dependencies? So, is there a way through which i could import the project in the offline environment?

Gaurav
  • 69
  • 2
  • 16
  • it needs the dependencies. It should work if all the dependencies are already present in your local repository – mahieus Feb 26 '19 at 09:35
  • possible duplicate with https://stackoverflow.com/questions/7233328/how-do-i-configure-maven-for-offline-development – Andrianekena Moise Feb 26 '19 at 09:35
  • 1
    Your local repository would normally be located in the `.m2` directory inside your user's home directory (`C:\users\username` on Windows, `/home/username` on Linux). You'd have to copy that repository to the offline machine as well otherwise it can't build because the dependencies aren't available ("offline" means "don't try to download the dependencies or any updates") – Thomas Feb 26 '19 at 09:39
  • @mahieus all the dependencies are located in the "C:\Users\dev1\project\GeoVision\target\GeoVision\WEB-INF\lib" directory but somehow its showing error is there something i need to do more? – Gaurav Feb 26 '19 at 09:46

1 Answers1

3

As pointed out by @Thomas, the only way to build a project which needs external dependencies with Maven is to copy the repository in the target environment. Build your project on an online environment, then copy your .m2 folder in the offline one. The build will then find all required libraries locally. With mvn dependency:go-offline you tell maven to download all the needed plugin dependencies in your local repository.

Matteo Baldi
  • 5,613
  • 10
  • 39
  • 51
  • I have two questions :- 1) Will this solution work if i am migrating my project to an another machine(offline) . 2) And is it necessary to build the project online first? – Gaurav Feb 26 '19 at 10:05
  • I've integrated my anwer with go-offline infos. 1) Yes. 2) Yes, if you only need a build in an offline environment, Maven is not what you're looking for. I've provided you a simple workaround. OR, you can create a custom repository (I'm using Nexus which works like an "online" repository without really going outside my network). – Matteo Baldi Feb 26 '19 at 10:08
  • Great so far it worked but when i try to run the application it show an load() exception "classnotfoundexception" and also all static files (js,css) are not loading and showing 404 ? – Gaurav Feb 26 '19 at 11:13
  • That's a different problem. Probably you are referring to online resources there (like a direct link to jQuery or similar) – Matteo Baldi Feb 26 '19 at 11:17
  • Can you integrate your question qith a complete stack trace? – Matteo Baldi Feb 26 '19 at 13:34