• Menu
  • Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

JavaBeat

Java Tutorial Blog

  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)
  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)

Maven : updatePolicy Configuration in Settings XML file

March 2, 2016 //  by Krishna Srinivasan//  Leave a Comment

One of the most common thing when working with dependency management is how often our local repository has to sync up with the remote repository. Maven has updatePolicy settings for specifying the frequency to check the updates in the repository. Most of the times this value is left blank in the configuration files, the default value is daily. This tutorial explains the use of this element in the settings.xml (global configuration file used for maven repository) file and what are the possible values that can be used for the updatePolicy element.

Maven updatePolicy Settings
Maven updatePolicy Settings

Here is the sample configuration snippet for setting the updatePolicy value:

<pluginRepositories>
	<pluginRepository>
		<id>Releases</id>
		<url>http://<host>:<port>/nexus/content/repositories/releases/</url>
		<releases>
			<enabled>true</enabled>
			<updatePolicy>daily</updatePolicy>
		</releases>
		<snapshots>
			<enabled>false</enabled>
		</snapshots>
	</pluginRepository>				
</pluginRepositories>

In the above example snippet, the settings tells the Maven that Releases repository (configured in local) has to check the remote repository for the artifacts every day. If it finds any updates to the artifacts, then it will download to the local repository. The timestamps are compared to the local POM’s timestamps (stored in a repository’s maven-metadata file). The possible choices for updatePolicy element are:

  • always
  • daily (this is the default value if you don’t specify any values
  • interval:X (where X is an integer in minutes)
  • never

Note that updatePolicy element itself an optional configuration. If don’t specify anything, it will take the default value. However, it is recommended to use always to download the latest updates available when ever uploaded to the repository. But, you should never use the value never for the updatePolicy. Sometimes, you may get the following error in the maven pom.xml file.

  • Also Read : How to create simple Java project using Maven

updatePolicy also applies to Maven meta data, For example, which versions are available and which one is the most current one. So, if there are any artifact versions already present in your local Maven repository, Maven will never download any version that is not yet present in your local repository. It will not download the newer versions from the remote repository.

Failure to find org.jfrog.maven.annomojo:maven-plugin-anno:jar:1.4.0 in http://myrepo:80/artifactory/repo was cached in the local repository, resolution will not be reattempted until the update interval of MyRepo has elapsed or updates are forced -> [Help 1]

The cause of this issue is that, in the local repository the file is not available. You can solve this problem by forcing the updates like this:

mvn clean install -U

Here -U means force updates.

Also Read : Create Web Application using Maven

I hope this tutorial helped you to understand the concepts of using updatePolicy element in the maven’s settings file. If you have any questions, please write it in the comments section.

 

Category: JavaTag: Apache Maven Configurations

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Previous Post: «New Features in Spring Boot 1.4 REST API Best Practices
Next Post: How To Add Environment Entries (JNDI) to Tomcat Web Server java»

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow Us

  • Facebook
  • Pinterest

FEATURED TUTORIALS

New Features in Spring Boot 1.4

Difference Between @RequestParam and @PathVariable in Spring MVC

What is new in Java 6.0 Collections API?

The Java 6.0 Compiler API

Introductiion to Jakarta Struts

What’s new in Struts 2.0? – Struts 2.0 Framework

JavaBeat

Copyright © by JavaBeat · All rights reserved
Privacy Policy | Contact