smuggledPancakes
smuggledPancakes

Reputation: 10333

Maven error on first step in tutorial

I am following a great looking tutorial at: http://www.objectdb.com/tutorial/jpa/eclipse/spring/project

On step one after copying in the code for the pom.xml, I get 9 errors. Here is the error that shows up on line 1 of my pom.xml:

Failure to transfer org.apache.maven.reporting:maven-reporting-api:jar:2.0.6 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.reporting:maven-reporting-api:jar:2.0.6 from/to central (http://repo.maven.apache.org/maven2): The operation was cancelled.   pom.xml /Guestbook  line 1  Maven Configuration Problem

I can post the other errors if necessary. I tried before this to run some simple pre-made maven projects, I believe they call them archtypes. They had similar errors. I don't understand why this is happening and I can't get some hello world thing to not throw errors immediately.

Upvotes: 0

Views: 3378

Answers (2)

Leo Lee
Leo Lee

Reputation: 488

In eclipse, right click under your project name, choose popup menu: Maven->Update Project. In the following dialog, check "Force Update of Snapshots/Releases", click "OK". Then maven will redownload the needed dependencies. Anyway, this solved my problem.Force Update

Upvotes: 0

chad
chad

Reputation: 7537

Say no to code voodoo. Don't nuke .m2!

When Maven tries to resolve dependencies for your build, it first looks in the local repository, aka .m2/repository. If it finds them there, it uses these locally cached artifacts. If the artifact doesn't exist in the local repository, Maven will attempt to resolve it from the remote repositories it knows about. Out of the box, it only knows about maven central. So, it will go there.

There is one major complication to scenario, which you are encountering. If a given dependency artifact is a SNAPSHOT artifact, then you will want to occassionally check for new versions of that artifact as the SNAPSHOT name is an indication that it is currently under development and could change frequently. To handle this, Maven is built to check once a day in remote repos for newer versions of any SNAPSHOT artifact that it has in the local repository.

Additionally, if it tries to find an arifact in a remote repository and get's some sort of failure -- commonly due to network relates issues that might be temporary or permanent ( network slowness or proxy set up ) -- this too failure is noted in the local repository meta-data. Like a SNAPSHOT resolution, this failure will persist as the state of the given artifact for 24 hours.

To override Maven's 24 hour policy, you do not have to nuke your local repository. You simply pass it the -U flag, which causes it to "update" all local artifact states, i.e. it will go out and recheck remote repositories for everything ( except for successfully resolved release artifacts -- releases are supposed to be permanent ) it knows about.

So, try:

mvn -U install

Not,

rm -Rf .m2

Upvotes: 5

Related Questions