?當我們使用搭建一個nexus本地倉庫,并且配置settings.xml來讓應用啟用這個倉庫。我們使用Liferay 6.1.10的archetype來創建liferay portlet, 如下圖:
?
當我們運行命令mvn package liferay:deploy時,會出現以下錯誤:
- [DEBUG]?Using?connector?WagonRepositoryConnector?with?priority?0?for?http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/?
- Downloading:?http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/com/sun/media/jai-codec/1.1.3/jai-codec-1.1.3.jar?
- [DEBUG]?Reading?resolution?tracking?file?C:\Documents?and?Settings\charles.wang\.m2\repository\com\sun\media\jai-codec\1.1.3\jai-codec-1.1.3.jar.lastUpdated?
- [DEBUG]?Writing?resolution?tracking?file?C:\Documents?and?Settings\charles.wang\.m2\repository\com\sun\media\jai-codec\1.1.3\jai-codec-1.1.3.jar.lastUpdated?
- [INFO]?------------------------------------------------------------------------?
- [INFO]?BUILD?FAILURE?
- [INFO]?------------------------------------------------------------------------?
- [INFO]?Total?time:?2.015s?
- [INFO]?Finished?at:?Sat?Jun?01?18:26:20?CST?2012?
- [INFO]?Final?Memory:?5M/9M?
- [INFO]?------------------------------------------------------------------------?
- [ERROR]?Failed?to?execute?goal?com.liferay.maven.plugins:liferay-maven-plugin:6.1.0:deploy?(default-cli)?on?project?charles-portlet:?Execution?default-cli?of?goal?com.liferay.maven.plugins:liferay-maven-plugin:6.1.0:deploy?failed:?Plugin?com.liferay.maven.plugins:liferay-maven-plugin:6.1.0?or?one?of?its?dependencies?could?not?be?resolved:?Could?not?find?artifact?com.sun.media:jai-codec:jar:1.1.3?in?nexus?(http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/)?->?[Help?1]?
- org.apache.maven.lifecycle.LifecycleExecutionException:?Failed?to?execute?goal?com.liferay.maven.plugins:liferay-maven-plugin:6.1.0:deploy?(default-cli)?on?project?charles-portlet:?Execution?default-cli?of?goal?com.liferay.maven.plugins:liferay-maven-plugin:6.1.0:deploy?failed:?Plugin?com.liferay.maven.plugins:liferay-maven-plugin:6.1.0?or?one?of?its?dependencies?could?not?be?resolved:?Could?not?find?artifact?com.sun.media:jai-codec:jar:1.1.3?in?nexus?(http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/)?
- ??????at?org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225)?
- ??????at?org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)?
- ??????at?org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)?
?
這個錯誤的原因是,Liferay版本為6.1的部署(deploy)插件版本太新了,而這個插件依賴于jai-codec版本為1.3的jar包,但是這個jar包在默認分組Public Repositories中找不到,所以出了這個問題。
?
為了解決這個問題,我們找了下,發現這個jai-codec.jar是JBoss 社區的,所以,我們重新配置nexus倉庫,我們新建一個JBoss_Repository, 如下圖所示:(注意,我們必須開啟?Download Remote Indexes選項)
?
然后我們把新建的"JBoss Repository"加到"Public Repositories" 組中。
?
最后,我們重新配置~/.m2目錄下的settings.xml,讓其開啟updatePolicy:
如261和270行所示,當把updatePolicy設為always時,構建過程不會從cache中獲取artifact,而是總是直接更新artifact:
?
最后,我們重新運行?mvn package liferay: deploy?命令:
?
可以看到這次 liferay:deploy過程不再有錯:
- [DEBUG]?Verifying?availability?of?C:\Documents?and?Settings\charles.wang\.m2\repository\com\liferay\portal\portal-impl\6.1.0\portal-impl-6.1.0.pom?from?[nexus?(http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/,?releases+snapshots)]?
- [DEBUG]?Skipped?remote?update?check?for?com.liferay.portal:portal-impl:pom:6.1.0,?locally?cached?artifact?up-to-date.?
- [DEBUG]?Using?connector?WagonRepositoryConnector?with?priority?0?for?http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/?
- Downloading:?http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/com/liferay/portal/portal-impl/6.1.0/portal-impl-6.1.0.pom?
- Downloaded:?http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/com/liferay/portal/portal-impl/6.1.0/portal-impl-6.1.0.pom?(0?B?at?0.0?KB/sec)?
- [DEBUG]?Reading?resolution?tracking?file?C:\Documents?and?Settings\charles.wang\.m2\repository\com\liferay\portal\portal-impl\6.1.0\portal-impl-6.1.0.pom.lastUpdated?
- [DEBUG]?Writing?resolution?tracking?file?C:\Documents?and?Settings\charles.wang\.m2\repository\com\liferay\portal\portal-impl\6.1.0\portal-impl-6.1.0.pom.lastUpdated?
- [DEBUG]?Verifying?availability?of?C:\Documents?and?Settings\charles.wang\.m2\repository\com\sun\media\jai-codec\1.1.3\jai-codec-1.1.3.pom?from?[nexus?(http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/,?releases+snapshots)]?
- [DEBUG]?Skipped?remote?update?check?for?com.sun.media:jai-codec:pom:1.1.3,?locally?cached?artifact?up-to-date.?
- [DEBUG]?Using?connector?WagonRepositoryConnector?with?priority?0?for?http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/?
- Downloading:?http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/com/sun/media/jai-codec/1.1.3/jai-codec-1.1.3.pom?
- Downloaded:?http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/com/sun/media/jai-codec/1.1.3/jai-codec-1.1.3.pom?(0?B?at?0.0?KB/sec)?
- [DEBUG]?Reading?resolution?tracking?file?C:\Documents?and?Settings\charles.wang\.m2\repository\com\sun\media\jai-codec\1.1.3\jai-codec-1.1.3.pom.lastUpdated?
- [DEBUG]?Writing?resolution?tracking?file?C:\Documents?and?Settings\charles.wang\.m2\repository\com\sun\media\jai-codec\1.1.3\jai-codec-1.1.3.pom.lastUpdated?
- [DEBUG]?Verifying?availability?of?C:\Documents?and?Settings\charles.wang\.m2\repository\javax\media\jai-core\1.1.3\jai-core-1.1.3.pom?from?[nexus?(http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/,?releases+snapshots)]?
- [DEBUG]?Using?connector?WagonRepositoryConnector?with?priority?0?for?http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/?
- Downloading:?http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/javax/media/jai-core/1.1.3/jai-core-1.1.3.pom?
- Downloaded:?http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/javax/media/jai-core/1.1.3/jai-core-1.1.3.pom?(0?B?at?0.0?KB/sec)?
- [DEBUG]?Reading?resolution?tracking?file?C:\Documents?and?Settings\charles.wang\.m2\repository\javax\media\jai-core\1.1.3\jai-core-1.1.3.pom.lastUpdated?
- [DEBUG]?Writing?resolution?tracking?file?C:\Documents?and?Settings\charles.wang\.m2\repository\javax\media\jai-core\1.1.3\jai-core-1.1.3.pom.lastUpdated?
- [ignore?some?output?here…]?
- [DEBUG]?Verifying?availability?of?C:\Documents?and?Settings\charles.wang\.m2\repository\com\liferay\portal\portal-impl\6.1.0\portal-impl-6.1.0.jar?from?[nexus?(http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/,?releases+snapshots)]?
- [DEBUG]?Verifying?availability?of?C:\Documents?and?Settings\charles.wang\.m2\repository\com\sun\media\jai-codec\1.1.3\jai-codec-1.1.3.jar?from?[nexus?(http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/,?releases+snapshots)]?
- [DEBUG]?Verifying?availability?of?C:\Documents?and?Settings\charles.wang\.m2\repository\javax\media\jai-core\1.1.3\jai-core-1.1.3.jar?from?[nexus?(http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/,?releases+snapshots)]?
- [DEBUG]?Skipped?remote?update?check?for?com.liferay.portal:portal-impl:jar:6.1.0,?locally?cached?artifact?up-to-date.?
- [DEBUG]?Skipped?remote?update?check?for?com.sun.media:jai-codec:jar:1.1.3,?locally?cached?artifact?up-to-date.?
- [DEBUG]?Using?connector?WagonRepositoryConnector?with?priority?0?for?http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/?
- Downloading:?http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/com/liferay/portal/portal-impl/6.1.0/portal-impl-6.1.0.jar?
- Downloading:?http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/com/sun/media/jai-codec/1.1.3/jai-codec-1.1.3.jar?
- Downloading:?http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/javax/media/jai-core/1.1.3/jai-core-1.1.3.jar?
- Downloaded:?http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/com/sun/media/jai-codec/1.1.3/jai-codec-1.1.3.jar?(0?B?at?0.0?KB/sec)?
- Downloaded:?http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/javax/media/jai-core/1.1.3/jai-core-1.1.3.jar?(0?B?at?0.0?KB/sec)?
- Downloaded:?http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public/com/liferay/portal/portal-impl/6.1.0/portal-impl-6.1.0.jar?(0?B?at?0.0?KB/sec)?
- [DEBUG]?Reading?resolution?tracking?file?C:\Documents?and?Settings\charles.wang\.m2\repository\com\liferay\portal\portal-impl\6.1.0\portal-impl-6.1.0.jar.lastUpdated?
- [DEBUG]?Writing?resolution?tracking?file?C:\Documents?and?Settings\charles.wang\.m2\repository\com\liferay\portal\portal-impl\6.1.0\portal-impl-6.1.0.jar.lastUpdated?
- [DEBUG]?Reading?resolution?tracking?file?C:\Documents?and?Settings\charles.wang\.m2\repository\com\sun\media\jai-codec\1.1.3\jai-codec-1.1.3.jar.lastUpdated?
- [DEBUG]?Writing?resolution?tracking?file?C:\Documents?and?Settings\charles.wang\.m2\repository\com\sun\media\jai-codec\1.1.3\jai-codec-1.1.3.jar.lastUpdated?
- [DEBUG]?Reading?resolution?tracking?file?C:\Documents?and?Settings\charles.wang\.m2\repository\javax\media\jai-core\1.1.3\jai-core-1.1.3.jar.lastUpdated?
- [DEBUG]?Writing?resolution?tracking?file?C:\Documents?and?Settings\charles.wang\.m2\repository\javax\media\jai-core\1.1.3\jai-core-1.1.3.jar.lastUpdated?
- [ignore?some?output?here…]?
- [DEBUG]?Configuring?mojo?com.liferay.maven.plugins:liferay-maven-plugin:6.1.0:deploy?from?plugin?realm?ClassRealm[plugin>com.liferay.maven.plugins:liferay-maven-plugin:6.1.0,?parent:?sun.misc.Launcher$AppClassLoader@11b86e7]?
- [DEBUG]?Configuring?mojo?'com.liferay.maven.plugins:liferay-maven-plugin:6.1.0:deploy'?with?basic?configurator?-->?
- [DEBUG]???(f)?autoDeployDir?=?D:\Liferay\RI\liferay-portal-6.1.0-ce-ga1\deploy?
- [DEBUG]???(f)?warFile?=?D:\Charles\Eclipse_Workspace\charles-portlet\target\charles-portlet-0.0.1-SNAPSHOT.war?
- [DEBUG]???(f)?warFileName?=?charles-portlet-0.0.1-SNAPSHOT.war?
- [DEBUG]?--?end?configuration?--?
- [INFO]?Deploying?charles-portlet-0.0.1-SNAPSHOT.war?to?D:\Liferay\RI\liferay-portal-6.1.0-ce-ga1\deploy?
- [INFO]?------------------------------------------------------------------------?
- [INFO]?BUILD?SUCCESS?
- [INFO]?------------------------------------------------------------------------?
- [INFO]?Total?time:?1:20.564s?
- [INFO]?Finished?at:?Mon?Jun?04?09:18:13?CST?2012?
- [INFO]?Final?Memory:?5M/11M?
- [INFO]?------------------------------------------------------------------------?