How to Change Maven Offline Mode

Maven is a great tool when it works; otherwise it’s pretty hard to figure out what’s happening and how to fix problems. Instead of detailing steps to get something done, the Maven philosophy is to let developers to pick what they want. For the common use cases that fit in its convention, Maven is pretty easy. In general, Maven is easy to start, and hard to customize.

Anyway, I got into one problem a few days ago. Somehow I figured out the problem and fixed it later, but still have no idea why it was changed that way.

Lost VMs or Containers? Too Many Consoles? Too Slow GUI? Time to learn how to "Google" and manage your VMware and clouds in a fast and secure HTML5 App.

A while back, I switched to NetBeans IDE due to its nice and integrated support for Maven. The experience has been really good. Normally I use Maven inside IDE, but for one project I had to use it with command line. So, I had to install the Maven as standalone and put the bin directory into the PATH environment variable. All worked well.

The project pom.xml file has a new plugin, which had never used on my machine before. So it had to be downloaded first. Somehow, it always stopped and failed the build. Initially I thought there was issue with the URL to the central repository, so I added explicitly repository section in the pom.xml. The problem persisted.

Plugin *** or one of its dependencies could not be resolved: Cannot access central (http://repo.maven.apache.org/maven2) in offline mode and the ***:jar:1.1 has not been downloaded from it before.

Reading carefully the output of the build failure showed that it’s offline mode somehow. After a bit research, the problem nailed down to the $HOME/.m2/settins.xml file. Somehow there is offline was set to be true. Therefore the maven command uses local repository only, which did not have the plugin yet.

<settings>
    ...
 
    <profiles>
        <profile>
            <id>netbeans-ide</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <netbeans.installation>C:\Program Files\NetBeans 8.0</netbeans.installation>
            </properties>
        </profile>
    </profiles>
 
    <offline>true</offline>
</settings>

The fix was pretty easy – just change the value of the offline tag to be false. It started to work nicely.

It made me to think why the offline was there. Normally it should not be the case. I don’t remember I had changed the file manually. It’s also possible that NetBeans IDE changed it. Anyway, it worked and I had no incentive to dig down but take a note about the problem in case it comes again.

This entry was posted in Applications & Tools and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

2 Comments

  1. Raichand Ray
    Posted September 8, 2015 at 2:11 am | Permalink

    Dear Sir,
    I also use Netbeans.It is a great tool.I wanted to create a CRUD application using netbeans using spring(not spring MVC),Primefaces,Hinernate,and mysql.I had added spring jars to libraries but it did not got built.I had followed an eclipse tutorial.No netbeans tutorial available please help me.
    Thanks
    Raichand Ray

  2. Posted September 8, 2015 at 10:33 am | Permalink

    Hi Richard, sorry to hear that. I don’t use Spring by myself, but if you use Maven you don’t add jars but add dependency in pom.xml. You may want to check Spring forum for more helps, or switch to the Eclipse based Spring IDE. Good luck!
    -Steve

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  • NEED HELP?


    My company has created products like vSearch ("Super vCenter"), vijavaNG APIs, EAM APIs, ICE tool. We also help clients with virtualization and cloud computing on customized development, training. Should you, or someone you know, need these products and services, please feel free to contact me: steve __AT__ doublecloud.org.

    Me: Steve Jin, VMware vExpert who authored the VMware VI and vSphere SDK by Prentice Hall, and created the de factor open source vSphere Java API while working at VMware engineering. Companies like Cisco, EMC, NetApp, HP, Dell, VMware, are among the users of the API and other tools I developed for their products, internal IT orchestration, and test automation.