2014-04-29 32 views
4

我有一個grails 2.3.8項目和一個Artifactory服務器。Grails Maven解析器不能與2.3.8一起工作

Artifactory服務器需要驗證。

BuildConfig.groovy包含:

grails.project.ivy.authentication = { 
    repositories { 
     mavenRepo "http://SERVER:8081/artifactory/remote-repos" 

    } 
    credentials { 
     realm = "Artifactory Realm" 
     host = "SERVER" 
     username = "USER" 
     password = "PASSWORD" 
    } 
} 


grails.project.dependency.resolver = "maven" // or ivy 

grails.project.dependency.resolution = { 
    // inherit Grails' default dependencies 
    inherits("global") { 
     // specify dependency exclusions here; for example, uncomment this to disable ehcache: 
     // excludes 'ehcache' 
    } 
    log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose' 
    checksums true // Whether to verify checksums on resolve 
    legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility 

    repositories { 
     inherits true // Whether to inherit repository definitions from plugins 

//  mavenLocal() 

     mavenRepo id: 'Artifactory', url: "http://SERVER:8081/artifactory/remote-repos" 

    } 

    dependencies { 

     runtime 'com.oracle:ojdbc6:11.2.0.1.0' 
     build "commons-dbcp:commons-dbcp:1.4" 

     compile 'org.jadira.usertype:usertype.jodatime:1.9' 
     compile "net.sf.ehcache:ehcache-core:2.4.6" 
    } 

    plugins { 
     runtime ":hibernate:3.6.10.13" 
     runtime ":resources:1.2.7" 

     build ":tomcat:7.0.52.1" 
     compile ':cache:1.1.5' 

     compile ":joda-time:1.4" 
    } 
} 

當我運行:

grails runApp 

我得到:

Starting process on MYPC/IPADDRESS 
Loading Grails 2.3.8 
|Configuring classpath 
Error | 
Resolve error obtaining dependencies: Failed to read artifact descriptor for xalan:serializer:jar:2.7.1 (Use --stacktrace to see the full trace) 
Error | 
Required Grails build dependencies were not found. This is normally due to internet connectivity issues (such as a misconfigured proxy) or missing repositories in grails-app/conf/BuildConfig.groovy. Please verify your configuration to continue. 

看起來像常春藤日誌配置並不適用於行家。我如何開啓日誌記錄?爲什麼我的工件不能解決?

+0

此外,我們背後的代理。代理設置通過Grails命令行上的add-proxy進行配置。不確定這是否相關,但Artifactory服務器也在防火牆內。 –

+0

如果您已經設置了'grails.project.dependency.resolver =「maven」'(而不是常青藤),是否會讀取'grails.project.ivy.authentication'設置? – nickdos

+0

我遇到了同樣的問題。你找到了解決方案嗎? – whitenexx

回答

0

嘗試改變:

grails.project.ivy.authentication = { 
    repositories { 
     mavenRepo "http://SERVER:8081/artifactory/remote-repos" 

    } 
    credentials { 
     realm = "Artifactory Realm" 
     host = "SERVER" 
     username = "USER" 
     password = "PASSWORD" 
    } 
} 

credentials { 
    realm = "Artifactory Realm" 
    host = "SERVER" 
    username = "USER" 
    password = "PASSWORD" 
} 

從常春藤到Maven的最近變化並不總是反映在文檔100%正確。您正在使用maven,所以我不認爲ivy設置將在此處起作用。

+1

感謝您的建議,但我得到相同的結果。 –

+0

同樣的問題在這裏... – whitenexx

0

嘗試下面的配置,您BuildConfig.groovy:

grails.project.dependency.resolver = "maven" 
grails.project.ivy.authentication = { 
    repositories { 
     mavenRepo('http://SERVER:8081/artifactory/remote-repos') { 
      auth([ 
       realm: "Artifactory Realm", 
       username: 'user', 
       password: 'pass' 
      ]) 
     } 
    } 
} 

grails.project.dependency.resolution = { 
    ... 
    repositories { 
     inherits true 
    } 
    ... 
} 
+0

感謝您的建議,但結果相同。 –

+0

找到這個鏈接。 http://grails.1312388.n4.nabble.com/Aether-dependencies-not-downloading-td4655575。html 但是現在在我的依賴項配置中多出了一個冒號 –

+0

嘗試從「grails.project.dependency.resolution」閉包中移除存儲庫。我已經測試過這個設置,它正在爲我工​​作。 –

1

有點晚的反應,但我遇到了這類問題,並追蹤到,告訴Artifactory的與404響應的設置而不是401,當有人從回購商那裏請求一件神器時,他們無法訪問。

我的猜測是,Grails的不先發制人依賴解析時進行身份驗證,所以它永遠不會嘗試使用在BuildConfig.groovy所提供的憑證獲取404

後嘗試關閉該設置,因爲它解決了該問題爲了我。

+0

這沒有奏效。我得到一個錯誤 - 「解決錯誤獲取依賴關係」 –

+0

供參考:這個artifactory設置是在**管理**選項卡 - > **安全** - > **一般** - > **「隱藏非授權資源的存在「**複選框。 「 ------------ 」當標記時,Artifactory通過向用戶無法訪問的資源請求發送404響應(未找到)隱藏未授權資源的存在,否則,響應意味着資源存在但受到保護 - 通過請求對匿名請求(401)進行身份驗證 或拒絕未經授權的用戶的已驗證請求。「 –