Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

where is the correct and recent ehcache maven repository

I've been struggling to get ehcache 2.1.0 in my environment. Anytime I thought I got it right, it's just not downloading it. Here is where I set the repository:

 <repository>
 <!--<url>https://oss.sonatype.org/content/repositories/releases/</url>-->
     <url>http://oss.sonatype.org/content/repositories/sourceforge-releases</url>
     <id>sonatype-mirror</id>
     <layout>default</layout>
     <name>Repository for library including ehcache recent ones</name>
 </repository>

And I add the dependency this way :

<dependency>
  <groupId>net.sf.ehcache</groupId>
  <artifactId>ehcache</artifactId>
  <version>2.1.0</version>
</dependency>

Is there anything that's i'm doing wrong or not properly?

like image 865
black sensei Avatar asked Dec 07 '10 18:12

black sensei


People also ask

Where are Maven repositories stored?

Local – Folder location on the local Dev machine Central – Repository provided by Maven community Let's now focus on the local repository. 2. The Local Repository The local repository of Maven is a directory on the local machine, where all the project artifacts are stored.

Why is Maven telling me to change the default repositories?

Basically, all Maven is telling you is that certain dependencies in your project are not available in the central maven repository. The default is to look in your local.m2 folder (local repository), and then any configured repositories in your POM, and then the central maven repository. Look at the repositories section of the Maven reference.

How to find the Central Maven repository in a pom?

The default is to look in your local .m2 folder (local repository), and then any configured repositories in your POM, and then the central maven repository. Look at the repositories section of the Maven reference.

Where are Maven dependency jars?

When a Maven build is executed, Maven automatically downloads all the dependency jars into the local repository. Usually, this directory is named .m2.


2 Answers

Ehcache is available in the maven central repository, there is no need to add a particular repository.

However, the ehcache artifact is special, it's an "aggregating" artifact which is of type pom. So the dependency should be declared like this:

<dependency>
  <groupId>net.sf.ehcache</groupId>
  <artifactId>ehcache</artifactId>
  <version>2.1.0</version>
  <type>pom</type>
</dependency>

Of course, you can also declare dependencies on individual modules if you want (e.g. ehcache-core) in which case you don't need to specify the type.

References

  • Ehcache Documentation
    • Java Requirements and Dependencies
like image 126
Pascal Thivent Avatar answered Sep 29 '22 15:09

Pascal Thivent


net.sf.ehcache:ehcache:2.1.0 is a dependency of type pom therefore you need to specify it:

<dependency> 
  <groupId>net.sf.ehcache</groupId> 
  <artifactId>ehcache</artifactId> 
  <version>2.1.0</version> 
  <type>pom</type>
</dependency> 

See also:

  • 3.6. POM Best Practices
like image 36
axtavt Avatar answered Sep 29 '22 15:09

axtavt