Maven error resolving dependency

I am new to Maven and trying to set up one of my first POM s. My application will cache using EhCache. Go to Maven Central Repo (link here ) I copied -n-pasted the <dependency> and copied it into my pom.xml as follows:

 ...many dependencies above this point <dependency> <scope>compile</scope> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>4.0.1.Final</version> </dependency> <dependency> <scope>compile</scope> <groupId>net.sf.ehcache</groupId> <artifactId>ehcache</artifactId> <version>2.5.0</version> </dependency> <dependency> <scope>compile</scope> <groupId>jasperreports</groupId> <artifactId>jasperreports</artifactId> <version>3.5.3</version> </dependency> ...many dependencies below this point 

When I save the changes, Eclipse creates a workspace and gives me an error when opening the <dependency> for EhCache 2.5:

Missing artifact net.sf.ehcache: ehcache: jar: 2.5.0

So, I realized that maybe v.2.5.0 is something wrong with him, and repeated the same for 2.4.7 (the latest 2.4.x release before 2.5.0 ). The same deal.

Since I'm so new to Maven, I don’t even know where to start looking. I tried Project >> Clean and even restarted Eclipse to make sure that it was just a typical Eclipse quirk. Not.

I think:

  • Can EhCache publish bad JAR files to Maven repository?
  • Can Maven Repo have something wrong with him?
  • Perhaps this is due to the fact that something else is not configured in my pom.xml ?
  • Could this be a "JAR hell" problem where I have a conflict somewhere on my dependency graph?

How will SO begin to solve this problem? Thanks in advance!

+6
source share
3 answers

It is usually safer to link to search.maven.org . Dependence on there:

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

Type of mind pom. From the pom module:

This is a pom artifact to pull ehcache-core and ehcache-terracotta for clustering. Remember to set the "type" to "pom" in your dependency.

Sometimes, when someone doesn’t need terracotta, the ehcache core will do well with other response states.

+8
source

They use ehcache-core in the official documentation . Maven Central does not have a jar artifact for ehcache 2.5 that explains your error message.

Using ehcache-core changes the dependency:

 <dependency> <groupId>net.sf.ehcache</groupId> <artifactId>ehcache-core</artifactId> <version>2.5.0</version> </dependency> 

Which successfully loads on my computer ( ehcache does not work).

+8
source

I threw it at IntelliJ and he found it. I suspect something is wrong with your settings. Try to create a project with only this dependency. If it does not load, I would check your settings. e.g. .m2/settings.xml Do you use a Nexus server or maven proxy / cache?

BTW: An easier way to search for JARs is to use http://mvnrepository.com/ , which will find all available versions and show you the XML you need to add.

0
source

Source: https://habr.com/ru/post/906547/


All Articles