2

Using İntelliJIdea, I Downloaded my project from Subversion for 12 times.

Deleted .m2/repository for 7-8 times.

Reimported, downloaded source for 15 times. Tried every possibilities but still cannot run my project.

Here is my Maven run profile and project hierarchy

project hiyerarchy

and here this is my maven output

[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact org.apache.maven.plugins:maven-clean-plugin:jar:2.5 has not been downloaded from it before. -> [Help 1]

http://paste.ubuntu.com/10613835/

There is nothing wrong with project or maven files. I'm running it on my work computer. But not in my personel.

Update1: After I deleted "-o" parameter in maven run configuration. Here is my new log Logs after deletig "-o" paramter and here is image url http://i.hizliresim.com/Lp6dDJ.png

Update2: I run this command on cmd, C:\MAYA\MAD4>mvn dependency:tree -Dverbose the result is success. And also saw C:\Users\tayfuny\.m2\repository\org\codehaus\plexus\plexus-digest\1.0\plexus-di‌​gest-1.0.jar in my dir. Here is latest maven output http://i.hizliresim.com/XBgD07.png

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
Tayfun Yaşar
  • 422
  • 2
  • 9
  • 24
  • Possible duplicate of [Could not transfer artifact org.apache.maven.plugins:maven-surefire-plugin:pom:2.7.1 from/to central (http://repo1.maven.org/maven2)](https://stackoverflow.com/questions/15334394/could-not-transfer-artifact-org-apache-maven-pluginsmaven-surefire-pluginpom2) – Goddard Aug 05 '19 at 15:23

2 Answers2

4

Update: Its early in the morning here in Switzerland - i have overseen you specified the -o parameter in your run configuration in the section Command line:. This is the console parameter to let Maven work offline ;) Remove it and you should be all good. Source: http://books.sonatype.com/mvnref-book/reference/running-sect-options.html

Update 2: Alright the initial problem is solved - your log however shows two more things to fix (one of them optionally but very recomended): 1.) The warnings at the very start of the build imply you have duplicate dependency/version declarations - those should be easy fixable. You can for example use mvn dependency:tree -Dverbose to get a overview on the duplicates (and which definition takes place in the end). The second is a actuall build error. I dont know about the install plugin you are using but i guess that you are missing this dependency: http://mvnrepository.com/artifact/org.codehaus.plexus/plexus-digest/1.0 (or another one containing the class that could not be found - adjust version as needed as well).

Answer regarding offline mode:

Remove the parameter -o when running maven unless you want to work in offline mode and with your local repository only.

Another probable cause is explicitly setting Maven to work in offline mode (e.g. only consult the local repository to resolve dependencies) from within the IDE itself (which will result in calling Maven with the -o parameter behind the scenes).

General Settings/ Project Settings:

File -> Settings -> Build, Execution, Deployment -> Build Tools -> Maven

(The very first option Work offline should be deactivated/ deselected unless you realy want to work with the local repository only).

Those settings are inherited by Maven-run configurations by default but may be overwritten at two levels

Default Run Configuration:

enter image description here (Those default configs will be inherited by specific run configurations. Note that changes to the general settings apply to newly created run configurations only and will not be populated to existing ones).

Specific Run Configuration: enter image description here

Make sure none of the options is selected. In the end if you use a specific launch configuration make sure the option is not selected in that specific configuration and change the higher levels for convenience if it makes sence)

JBA
  • 2,769
  • 5
  • 24
  • 40
  • its not selected. http://i.hizliresim.com/6Z1R1l.jpg thanks for answer JBA. I also tried every combination here too. – Tayfun Yaşar Mar 17 '15 at 07:05
  • @tayfun hehe - i've seen it just now rethinking what it might be then - see my update in the answer :) – JBA Mar 17 '15 at 07:20
  • i removed "-o" paramter. it look like this now http://i.hizliresim.com/j4DJ79.jpg here is new log. http://paste.ubuntu.com/10614045/ thanks for answer again :) – Tayfun Yaşar Mar 17 '15 at 07:38
  • @tayfun you are very welcome - mind to add the new log to the question? (I cant access the second link from within the company due to firewall restrictions) – JBA Mar 17 '15 at 08:05
  • added to my first topic "Update1" – Tayfun Yaşar Mar 17 '15 at 08:09
  • @tayfun sorry i meant to add the content of the log (or upload a image like to that i.hizliresim.com-thing) - when i click the link the company firewall is blocking my request (others will normaly see it for further assistance but as you see on the post views Maven is not the hotspot of attention on SO :)) – JBA Mar 17 '15 at 08:29
  • sorry for misunderstaning :) added under "update1" http://i.hizliresim.com/Lp6dDJ.png – Tayfun Yaşar Mar 17 '15 at 08:48
  • Alright i am now able to view the log - updating answer :) – JBA Mar 17 '15 at 08:54
  • I did "C:\MAYA\MAD4>mvn dependency:tree -Dverbose" the result is success. also saw "C:\Users\tayfuny\.m2\repository\org\codehaus\plexus\plexus-digest\1.0\plexus-digest-1.0.jar" in my dir. updated my answer, added new pic into 1st post http://i.hizliresim.com/XBgD07.png :/ – Tayfun Yaşar Mar 17 '15 at 11:30
  • @tayfun right before the build success of `mvn dependency:tree -Dverbose` you will see the `[INFO]` telling you about the resolved (and "omitted for duplicate") dependencie tree - regarding this we are talking about warnings that wont corrupt your build and are generally just solved for a "better" build (oftenly the `enforcer` plugin is added to the build to make it fail on things like convergence errors. – JBA Mar 17 '15 at 11:36
  • Regarding the second issue this could be helpful: http://stackoverflow.com/questions/17223536/failed-to-execute-goal-org-apache-maven-pluginsmaven-compiler-plugin2-3-2comp since my previous comment was wrong - if you have plugins to be executed within your build you do not need to define dependencies those plugins require from within your pom.xml file. – JBA Mar 17 '15 at 11:38
  • So now your `-o` issue is solved consider deleting the entire local repository and rebuild the project (or of corse if that did not solve it feel free to first search SO for similar questions regarding this `NoClassDefFoundError` or open a new question if you havent found a solution on existing Q&As) – JBA Mar 17 '15 at 11:42
  • And another simple cause to check: https://blogs.oracle.com/sreekanth/entry/java_lang_noclassdeffounderror_org_codehaus – JBA Mar 17 '15 at 11:43
  • lets continue here http://stackoverflow.com/questions/29098424/maven-install-error-failed-to-execute-goal-org-apache-maven-pluginsmaven-ins – Tayfun Yaşar Mar 17 '15 at 11:54
  • @tayfun that sounds like a plan for others to further support you. Consider deleting the entire local repository again since you removed the `-o` parameter (just one time more :)). Regarding your new question one thing comes up to my mind but i dont have time to verify it: "is it necessary to have at least one environment variable pointing to maven?", "is Maven correctly configured if runned out of a IDE?" – JBA Mar 17 '15 at 12:09
  • i run it on eclipse correctly but still not work in intellij :/ – Tayfun Yaşar Mar 18 '15 at 07:18
  • @tayfun alright thats already good to hear - now my issue is i dont know much about the `m2 plugin` that is used to integrate Maven into eclipse - this could do something else than what the maven standard process might look like - i recomend adding this detail to your new question since it looks like you now have a valid maven project in eclipse that seems to not be runnable/ working in Intellij. – JBA Mar 18 '15 at 07:26
  • I was struggling for 2 hours. I didn't notice the error message about trying to get dependencies in OFFLINE MODE. Then I unticked offline mode in maven settings. This post literally opened my eyes... :-D – Rohit Singh Jan 17 '17 at 12:15
0

EASY WAY

This should work for all similar errors.

This is how an error looks like

  • Could not resolve : org.apache.maven.plugins:maven-clean-plugin:jar:2.5

  • Could not resolve : (groupID):(artifactID):version

So what you actually need is a correct version of the clean plugin.

<dependency>
  <groupId>(groupId)</groupId>
  <artifactId>(artifactId)</artifactId>
  <version>(version)</version>
  <type>maven-plugin</type>
</dependency>

This will become something like this. Add this to dependencies section Pom.xml. Reload build.

<dependency>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>3.0.0-M5</version>
  <type>maven-plugin</type>
</dependency> 

Reload build and IDE will automatically download these version of artefacts and replace if there are other versions because your project needs these particular versions to run.

Do the same with other dependency errors. "Works every time".

oshin pojta
  • 89
  • 1
  • 6