dependency resolution - Maven fails to find local artifact

文章推薦指數: 80 %
投票人數:10人

This means that there's no local repository used when resolving dependencies (though your installed artifacts do still get put in the default location). Home Public Questions Tags Users Companies Collectives ExploreCollectives Teams StackOverflowforTeams –Startcollaboratingandsharingorganizationalknowledge. CreateafreeTeam WhyTeams? Teams CreatefreeTeam Collectives™onStackOverflow Findcentralized,trustedcontentandcollaboratearoundthetechnologiesyouusemost. Learnmore Teams Q&Aforwork Connectandshareknowledgewithinasinglelocationthatisstructuredandeasytosearch. Learnmore Mavenfailstofindlocalartifact AskQuestion Asked 9years,9monthsago Modified 9monthsago Viewed 216ktimes 132 26 Occasionallymavencomplainsthataparticulardependency,whichisbuiltandpackagedlocally,cannotbefoundinthelocalrepositorywhilebuildinganotherprojectthathasitasadependency.Wegetanerrorlike: FailedtoexecutegoalonprojectX:CouldnotresolvedependenciesforprojectX:FailuretofindYin[archivarepository]wascachedinthelocalrepository,resolutionwillnotbereattempteduntiltheupdateintervalofinternalhaselapsedorupdatesareforced-> WhereXistheprojectbeingbuilt,andYisthesupposedlymissingartifact.Ifyoulookinthelocalrepository,theartifactisthere.Thisartifactisneverinstalledinourarchivarepository,sotheproblemispurelybasedinthelocalrepository. Wehavetriedvariousprofilesinsettings.xml,andofcourse"mvn-U".Neitherdoanygood,norshouldtheybecausethisartifactnevergoesanyfurtherthanthelocalrepository. Theonlytwothingsthatseemtoworkaretowaitaverylongtimeuntilmavensmartensup,ortocompletelydeletethelocalrepository.Presumablythewaitingoptionisrelatedtotheaforementionedupdateinterval. Wehaveexperiencedthisproblemwithmaven3.0.2and3.0.3.WeareusingArchiva1.0.3(butagainthisshouldn'tbeafactor).Anyhelpwouldbegreatlyappreciated. mavendependency-resolution Share Improvethisquestion Follow editedFeb3,2020at14:49 mzjn 45.8k1111goldbadges120120silverbadges232232bronzebadges askedSep20,2012at16:44 user1686620user1686620 2,54144goldbadges1616silverbadges1717bronzebadges 7 1 IsMavenlogginganythingwhileorjustbeforethe"waiting?"I.e.isitattemptingtoconnecttoanunreachablerepository?Also,aretheproblematicartifacts"-SNAPSHOT"? – noahlz Sep20,2012at16:53 Mavendoesn'tloganythingotherthantheerrorImentionedabove.Andyesthisisasnapshotdependency. – user1686620 Sep20,2012at17:02 1 Seestackoverflow.com/questions/1348603/… – noahlz Sep20,2012at17:05 1 Haveyouinstalledthebuildpackagebeforeyoutrytobuildthesecondproject? – khmarbaise Sep21,2012at7:15 3 Ilikehowtheerrormessageisarun-on,notagrammaticallycorrectsentence.Thisway,wedon'tknowforsureifitcannotfindYorifYwascachedlocally,orboth.Anyway,Ihaveasimilarproblem.Iwasabletoresolveitwiththe-Uoptionbecausemydependenciesareinmycompany'sinternalrepo.Whyaren'ttheartifactsyouneeddeployedtoyourcompany'sinternalrepository? – jyoungdev Feb18,2013at17:22  |  Show2morecomments 17Answers 17 Sortedby: Resettodefault Highestscore(default) Datemodified(newestfirst) Datecreated(oldestfirst) 103 ThelocalMavenrepotrackswhereartifactsoriginallycamefromusingafilenamed"_maven.repositories"intheartifactdirectory.Afterremovingit,thebuildworked.Thisanswerfixedtheproblemforme. Share Improvethisanswer Follow editedMay23,2017at11:55 CommunityBot 111silverbadge answeredJan22,2014at12:52 jhansonjhanson 1,08411goldbadge88silverbadges66bronzebadges 8 36 Formeitwasafilenamed"_remote.repositories".Iremoveditanditworked!Thankforthetricks! – perbellinio Apr27,2015at13:02 2 Thxthefilenamed_remote.repositorieswasalsopresent.ithappenedtomewhenournexusstophavingnetworkconnectionsoitcantobtainthedependencies – cabaji99 Feb2,2018at13:10 2 Theprovidedsolutiondoeswork.However,Iaminterestedinwhythisproblemoccurrsatall.Couldanybodyprovidemewithaquickexplanation?DoIhavetodosomethingdifferently? – Janothan Feb26,2019at13:44 Ifyouwanttobypassthisorigincheckonce(withoutdeletingthemetafiles),trypassingaether.enhancedLocalRepository.trackingFilename=some_dummy_file_nametothedependencyresolutionprocess;easiestwayistoadda-Dsystempropertytotheinvocationcommand. – JanakaBandara Apr22,2019at3:48 1 @JanothanIMOthelinkintheanswerprovidesaprettygoodexplanation:) – JanakaBandara Apr22,2019at3:50  |  Show3morecomments 53 Astheoptionsheredidn'tworkforme,I'msharinghowIsolvedit: Myprojecthasaparentproject(withitsownpom.xml)thathasmanychildrenmodules,oneofwhich(A)hasadependencytoanotherchild(B).WhenItriedmvnpackageinA,itdidn'tworkbecauseBcouldnotberesolved. Executingmvninstallintheparentdirectorydidthejob.Afterthat,IcoulddomvnpackageinsideofAandonlythenitcouldfindB. Share Improvethisanswer Follow editedJan14,2019at13:34 Sampath 1,02911goldbadge2020silverbadges3838bronzebadges answeredJul13,2017at5:56 FlorianPfistererFlorianPfisterer 1,1451111silverbadges2121bronzebadges 2 3 THANKYOU!thiswasdrivingmecrazy.mvncleanpackagejboss-as:deploywasworkingwhenIexecutedonasingleline,butnotwhenIdidthemseparately. – PMorganCA Nov7,2017at20:10 Thanks,thissolutionsavedmefromwastingtime – Skywarp Jun2at15:23 Addacomment  |  24 Eveninofflinemode,mavenwillcheckremoterepositoriesifthereisa_remote.repositoriesmarkerforthedependency.Ifyouneedtooperateinofflinemode,youmayneedtodeletethesefiles. Thesimpleshellcommandbelowdeletesthesemarkerfiles.Thisissafetodoifyouonlyuseofflinemodeforthemachine.IwouldNOTdothisonamachinethatneedstopullfilesdownfromtheweb. Ihaveusedthisstrategyonabuildserverthatisdisconnectedfromtheweb.Wehavetotransfertherepositorytoit,deletethemarkerfilesandthenruninofflinemode. OnLinux/Unixyoucandeletetheremoterepositorymarkerfilesthisway: cd~/.m2 find.-name"_remote.repositories"-typef-delete Share Improvethisanswer Follow editedNov7,2018at20:00 DrB 27411goldbadge33silverbadges1414bronzebadges answeredNov16,2017at19:51 JonJon 3,0122727silverbadges3535bronzebadges 3 1 Thissolutionworkedforme,foradependencyIcopiedoverfromanothercomputerwhichisnotavailableinacentralrepository.Thecommandthoughmissesafewcharacters.Hereisthefullcommand:find.-name"_remote.repositories"-type-f-delete – HansDeragon Aug11,2018at9:19 2 Or,insteadofdeleting,youshouldbeableto"misguide"Maventonotlookatthe_remote.repositoriesfilebypassing-Daether.enhancedLocalRepository.trackingFilename=some_dummy_file_nametotheprocess.(Didn'ttryonanactualMavenbuild,butworkswheninvokingMavenprogrammatically;sotheformershouldalsowork) – JanakaBandara Apr22,2019at3:53 1 Ididthisfindinganddeletingspecificdependencies(jars)notfoundbyMaven,sincetheywerelistedandmanageabletoto(<10).ThiswasduetoamisconfigpointingtoaremoteNexusnotcurrentlyavailable(asIunderstood..).Sonoactualneedtosweepallrepofordeletion.Anywaythissolutionsavedtheday.Itworkforme. – Diego1974 May10,2019at12:33 Addacomment  |  12 Whenthishappenedtome,itwasbecauseI'dblindlycopiedmysettings.xmlfromatemplateanditstillhadtheblankelement.Thismeansthatthere'snolocalrepositoryusedwhenresolvingdependencies(thoughyourinstalledartifactsdostillgetputinthedefaultlocation).WhenI'dreplacedthatwith${user.home}\.m2\repositoryitstartedworking. For*nix,thatwouldbe${user.home}/.m2/repository,Isuppose. Share Improvethisanswer Follow editedJan21,2014at20:52 answeredJan20,2014at2:27 PaulHicksPaulHicks 12.4k44goldbadges4545silverbadges7272bronzebadges 1 7 ${user.home}\.m2\repositoryisthedefaultsoremovingtheemptytagshouldworkalike. – LMC Oct9,2015at20:37 Addacomment  |  12 Mavenrememberswhenitdidn'tfindsomething.Thekeyis"resolutionwillnotbereattempteduntiltheupdateintervalofinternalhaselapsedorupdatesareforced->" Thequicksolutionistodeleteyourlocal"repository"subdirectoryfortheproblemartifact-assumingyouhavefixedtheproblemwithit.:) mvn-Uwillforceupdatefromremoterepository-again,assumingyouhavenowpopulatedremotewithsaidartifact. Share Improvethisanswer Follow answeredSep17,2014at21:58 AndreAndre 36033silverbadges88bronzebadges 1 Suchasimplefix,solittleattentionpaidtoit.(clap) – Darek Oct30,2020at15:09 Addacomment  |  6 Ifyouhavedefinedinyourpom.xmlapparentlyyourlocalrepositoryisignored. Share Improvethisanswer Follow answeredJan17,2020at19:55 JaroslavZárubaJaroslavZáruba 4,48644goldbadges3636silverbadges5454bronzebadges Addacomment  |  3 Catchall.Whensolutionsmentionedheredon'twork(happendinmycase),simplydeleteallcontentsfrom'.m2'folder/directory,anddomvncleaninstall. Share Improvethisanswer Follow answeredJul20,2019at1:02 lupchiazoemlupchiazoem 7,92655goldbadges3535silverbadges4141bronzebadges 1 Yep.thisanswerworkedbutdependency:go-offlinedidnotworkforme.Somisleading. – djangofan Dec1,2020at19:52 Addacomment  |  2 EvenIfacedthisissueandsolveditwith2ways: 1)InyourIDEselectprojectandcleanallprojectstheninstallallthemavendependenciesbyrightclickingonproject->gotomavenandUpdateprojectdependenciesselectallprojectsatoncetoinstallthesame.Oncethisisdoneruntheparticularproject 2)ElseWhatyoucandoischeckinthepom.xmlforthedependenciesforwhichyouaregettingerrorand"mvncleaninstall"thosedependentprojectfirstandtheinstallmavendependenciesofthecurrentprojectinwhichyoufacingissue.Bythisthedependenciesofthelocalprojectwillbebuildandjarswillbecreated. Share Improvethisanswer Follow answeredMay28,2019at12:10 NehaTawarNehaTawar 65966silverbadges2121bronzebadges Addacomment  |  0 Iruntothesimilarproblemwhenmynewprojectdependonoraclejdbcjar(whichIhaveinstalledinmylocalrepositoryandworkwellforotherprojects).Itried-Uoption,deleting.lastupdatefileorthewholedirectoryanddownlaodagain,butitdidnotwork.finally,Ideletedthedirectoryandinstalleditlocallyagain,itworks. Share Improvethisanswer Follow answeredMar10,2015at7:37 yuxhyuxh 87411goldbadge88silverbadges2323bronzebadges Addacomment  |  0 OneoftheerrorsIfoundaroundMaveniswhenIputmysettings.xmlfileinthewrongdirectory.Ithastobein.m2folderunderyouruserhomedir.Checktomakesurethatisintherightplace(alongwithsettings-security.xmlifyouareusingthat). Share Improvethisanswer Follow answeredNov7,2015at2:36 AshikUzzamanAshikUzzaman 1 Addacomment  |  0 IhadDependencyResolutionExceptioninUbuntuLinuxwhenI'veinstalledlocalartifactsviaashellscript.Thesolutionwastodeletethelocalartifactsandinstallthemagain"manually"-callingmvninstall:install-fileviaterminal. Share Improvethisanswer Follow answeredJan16,2017at4:05 naXastandswithUkrainenaXastandswithUkraine 31.1k1616goldbadges175175silverbadges239239bronzebadges Addacomment  |  0 ThishappenedbecauseIhadhttpinsteadofhttpsinthis: jcenter jcenter-bintray https://jcenter.bintray.com Share Improvethisanswer Follow answeredApr17,2020at22:39 parsecerparsecer 3,87299goldbadges4949silverbadges105105bronzebadges Addacomment  |  0 checkififyourartifactYhavepackagingsetto"jar".Ifyouhavedefineditas"war"byerrororcopypaste,itwillshowthisstrange"wascachedinthelocalrepository,resolutionwillnotbereattempteduntiltheupdateintervalofinternalhaselapsedorupdatesareforced".Iwouldexpectsomethinglike"artifactYiswar,jartypeexpected". Share Improvethisanswer Follow answeredAug14,2020at8:24 PatrikHrmoPatrikHrmo 111bronzebadge 1 thissolutionispartiallycorrect,whichpointedmytowardstherightanswer.InmycaseIwantedYtobeWARsoIpackageditbothasJARandWAR,andimportedtheJARinprojectX.Checkmyanswerforadetailedapproachtodothis. – DimiAnsari Dec16,2020at8:07 Addacomment  |  0 InmycaseIneededprojectYtobeaWARtobedeployedthroughTomcat,aswellasitneededtobeaJARtobeabletoadditasadependencyinprojectX. SoinprojectY'spom.xml,IaddedthisplugintocreateaJARalongwiththeWAR: maven-war-plugin 3.2.2 true classes AndwhileaddingthedependencyofprojectYinprojectX'spom.xml,Ihadtoaddaclassifier: groupId.of.project.Y project.Y 1.0-SNAPSHOT classes Note:whenyoubuildprojectY,youwillsee2packagingsinthetargetfolder:project-Y.warandproject-Y-classes.jar,sothat'swhywhileimportingyouarespecifyingtheclassesclassifiertoimporttheJARandnottheWAR. Share Improvethisanswer Follow answeredDec16,2020at8:05 DimiAnsariDimiAnsari 15611silverbadge1313bronzebadges Addacomment  |  0 HereisthelongSolutiontotheproblem (NotQuickfixbutwillworkifnoothersolution) You'regoingtohatemeforsayingthisbutthisisthetruthaboutopensourceprojectslikeeclipse.BecauseOpensourceismodularandallowsyoutobuildanddevelopaprojectinmanywayswithmanytoolssuchasmaven,springboot,optionsforxmlorgroovy,differenteclipseupdates&Etc.TheproblemisthateclipseallowsyoutoruntheprojectwithmissingmavenbuildsbecausetheIDEissmartenoughtoresolvedependenciesusingaremote_repositorywhereitstoresandcatchesthejarfilesthatisnotproperlybuiltontheproject. Becauseofthisfeature,YoumayactuallyhavelocalbuildissuesbutjustlikeDNSservers;ifthesolutionisnotfoundinthelocaldirectory,Eclipsewilllookforasolutioninit'sremotecachedrepository.Whenyoudeletetheremote_repositoryandletMavenrebuilditasecondtime,Theprojectmayendupcreatingmoreerrorsandnotbuildasecondtimeormaypossiblyrebuildacachethatwasmissing.Butthatisunlikely. Sothelonganswertofixyoursolution. Thisisaprojectarchitectureissue! SOLUTION: Whatyouneedtodoislookintoallyourdependantproject'spom.xmlfileandthemavendependenciesfolderinyourlocalprojectandtrytoresolveallthemissingdependencyjarsinyourmavendependencyfolder.Ifyouhaveareferencedlibrary,Isuggestmovingthosejarsintoyourlocalproject'smavendependencyfolder. YouhavetoworkyourwayintosolvingeverychildprojectandthennavigateintoyourrootprojectandfixeverysingleprojectbyusingMaven->Build->cleaninstall(checkoff"skiptests"&"resolveworkspaceartifacts")untileveryprojectbuildswithacleansuccess. mostlikely,whenyouforceupdateyourentiresolutiontoallyourprojects,youwillgetalistoferrorsthatyouhavetheIDEauto-resolve.Theauto-resolvewillrefertoaeasyreferencetofixtheissue.Buttodeploy,youhavetomanuallyfixtheprojectbecauseEclipse,Spring&Mavenwillworkwelltogetherbuttherearemaybeafewthingstheydon'tagreeon.So,youhavetoplaydiplomatinthosesituationsandfigureitout. That'sthesadtruth. Allsaid,Ihavealistofproblemsinmyproject.Ihavethisissue.Thewarfilegeneratedhasemptyjarfoldersandthebuildisnotcleanwithouterrorsunlessiforceit.TheWARfilegeneratewillruna404errorontomcatserverproductionandmyangularapplicationwillthrowaCors-ErrorwhenexecutingtheAPI. AlltheerrorsonmyfrontendprojectisartificialbecausetherootofallissuesistheWARfilegenerated.Itdidnotgeneratewithdependencies,theMainprojectdidnotexecuteintomcatandtomcatservercannotrunthespringinitializertodeploythecors-policyontheservertoallowmyangularapplicationtocommunicate.Butallinall,developmentenvironmentworksfinewithnoissues. Sothatismylongendedsolutionforthisthread. Share Improvethisanswer Follow answeredAug31,2021at2:53 RafatKhandakerRafatKhandaker 111bronzebadge Addacomment  |  -1 Ihadthesameerrorfromadifferentcause:I'dcreatedastarterPOMcontainingour"goodpractice"dependencies,andbuilt&installeditlocallytotestit.Icould"see"itintherepo,butaprojectthatuseditgottheaboveerror.WhatI'ddonewassetthestarterPOMtopom,sotherewasnoJAR.Mavenwasquitecorrectthatitwasn'tinNexus--butIwasn'texpectingittobe,sotheerrorwas,ummm,unhelpful.ChangingthestarterPOMtonormalpackaging&reinstallingfixedtheissue. Share Improvethisanswer Follow answeredJun3,2020at11:50 EdmundSSEdmundSS 1 1 Thisanswerwouldprobablyhavebeenbetterasacomment,sinceitisn'tadirectanswertothequestion. – 00prometheus Jun3,2020at12:18 Addacomment  |  -1 InmycaseIhadtoaddmavenLocal()inrootlevelgradledependency mavenCentral() mavenLocal() Share Improvethisanswer Follow answeredApr25,2021at7:11 HiteshSahuHiteshSahu 38.4k1515goldbadges183183silverbadges143143bronzebadges Addacomment  |  YourAnswer ThanksforcontributingananswertoStackOverflow!Pleasebesuretoanswerthequestion.Providedetailsandshareyourresearch!Butavoid…Askingforhelp,clarification,orrespondingtootheranswers.Makingstatementsbasedonopinion;backthemupwithreferencesorpersonalexperience.Tolearnmore,seeourtipsonwritinggreatanswers. Draftsaved Draftdiscarded Signuporlogin SignupusingGoogle SignupusingFacebook SignupusingEmailandPassword Submit Postasaguest Name Email Required,butnevershown PostYourAnswer Discard Byclicking“PostYourAnswer”,youagreetoourtermsofservice,privacypolicyandcookiepolicy Nottheansweryou'relookingfor?Browseotherquestionstaggedmavendependency-resolutionoraskyourownquestion. TheOverflowBlog Privacyisamovingtarget.Here’showengineeringteamscanstayontrack... OurfavoritefeaturesandupdatesfromWWDC(Ep.454) FeaturedonMeta AnnouncingthearrivalofValuedAssociate#1214:Dalmarus Testingnewtrafficmanagementtool AskWizardTestResultsandNextSteps Linked 0 MavensearchesanartifactinCentralthatisavailableinlocal 137 HowcanIgetMaventostopattemptingtocheckforupdatesforartifactsfromacertaingroupfrommaven-central-repo? 42 mavencan'tfindmylocalartifacts 2 Mavencan'tfindpackage 0 Mavenresolutionforexistingartifactfails Related 740 Whenmavensays"resolutionwillnotbereattempteduntiltheupdateintervalofMyRepohaselapsed",whereisthatintervalspecified? 1470 HowtoaddlocaljarfilestoaMavenproject? 324 Mavenerror"Failuretotransfer..." 716 IntelliJinspectiongives"Cannotresolvesymbol"butstillcompilescode 159 SpecifyingMaven'slocalrepositorylocationasaCLIparameter 257 HowdoyouclearApacheMaven'scache? 104 Couldnottransferartifactorg.apache.maven.plugins:maven-surefire-plugin:pom:2.7.1from/tocentral(http://repo1.maven.org/maven2) 1 MavenSitescannotation.jar 143 HowdoIforceMaventousemylocalrepositoryratherthangoingouttoremoterepostoretrieveartifacts? 1 Whycan'tmavenfindanartifactlocatedinahostedrepository? HotNetworkQuestions Couldahandlaunchedmissilework? CanIputaGFIoutlethere? Truncatewordsinasentence Isitsafetokeepvolcanicsulfurathome? What'sthepurposeoftheband-passfilterinanRFtransmitter? Whatisthepurposeofatreadpatternoncity/roadtyres? Doeslocalblockchaindatabase(blkXXXXX.dat)containabandonedforksforever? IsitagoodtimeorgoodideatoinvestmoneythatIwillneedtorepayinayeartimethatisnotcurrentlyaccumulatinginterest? Howtomakesomethinglookcoveredinsoil,withoutriskofstaining/marking HowdoesIRSknowthatIcalculatedtaxusingworksheet"QualifiedDividendsandCapitalGainTaxWorksheet" Is"AveDominusNox"thecorrecttranslationfor"HailtotheLordofNight"? WhydoesthekoboldinventorinTombofAnnihilationreferenceAppendixA? WhereisRabbiAkivatoldtosticktoHalachaandnottryAggadah? Needsamplesofcopyleftnotices StatisticalinterpretationofdiagonalofCholeskydecomposition? Whyhasn'tIsraelimposedsanctionsonRussia? WhydoesWindowsmagically"couple"somefileslikethis? HowcanIrepeatonlyapartofacommandinbash? Isitnormalforrigidbodysimulationtobetooslow? Doesphasekickbackrequirethesystemtobeintheeigenstate? Whatdoyouputforcompanylocationonaresume/jobapplicationinthisscenario? TheclassofspaceswhereeveryBorelmeasureisatomic IsKhanAcademywrongaboutinflation? Areantennasspecifiedforacertainfrequency? morehotquestions Questionfeed SubscribetoRSS Questionfeed TosubscribetothisRSSfeed,copyandpastethisURLintoyourRSSreader. lang-xml Yourprivacy Byclicking“Acceptallcookies”,youagreeStackExchangecanstorecookiesonyourdeviceanddiscloseinformationinaccordancewithourCookiePolicy. Acceptallcookies Customizesettings  



請為這篇文章評分?