当我们使用搭建一个nexus本地仓库,并且配置settings.xml来让应用启用这个仓库。我们使用Liferay 6.1.10的archetype来创建liferay portlet, 如下图:

 

当我们运行命令mvn package liferay:deploy时,会出现以下错误:

 
  
  1. [DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public
  2. 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 
  3. [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 
  4. [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 
  5. [INFO] ------------------------------------------------------------------------ 
  6. [INFO] BUILD FAILURE 
  7. [INFO] ------------------------------------------------------------------------ 
  8. [INFO] Total time: 2.015s 
  9. [INFO] Finished at: Sat Jun 01 18:26:20 CST 2012 
  10. [INFO] Final Memory: 5M/9M 
  11. [INFO] ------------------------------------------------------------------------ 
  12. [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] 
  13. 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/) 
  14.       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:225) 
  15.       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 
  16.       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过程不再有错:

 
  
  1. [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)] 
  2. [DEBUG] Skipped remote update check for com.liferay.portal:portal-impl:pom:6.1.0, locally cached artifact up-to-date
  3. [DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public
  4. 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 
  5. 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) 
  6. [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 
  7. [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 
  8. [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)] 
  9. [DEBUG] Skipped remote update check for com.sun.media:jai-codec:pom:1.1.3, locally cached artifact up-to-date
  10. [DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public
  11. 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 
  12. 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) 
  13. [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 
  14. [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 
  15. [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)] 
  16. [DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public
  17. 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 
  18. 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) 
  19. [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 
  20. [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 
  21. [ignore some output here…] 
  22. [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)] 
  23. [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)] 
  24. [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)] 
  25. [DEBUG] Skipped remote update check for com.liferay.portal:portal-impl:jar:6.1.0, locally cached artifact up-to-date
  26. [DEBUG] Skipped remote update check for com.sun.media:jai-codec:jar:1.1.3, locally cached artifact up-to-date
  27. [DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://192.168.129.35:8080/nexus-2.0.4-1/content/groups/public
  28. 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 
  29. 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 
  30. 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 
  31. 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) 
  32. 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) 
  33. 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) 
  34. [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 
  35. [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 
  36. [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 
  37. [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 
  38. [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 
  39. [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 
  40. [ignore some output here…] 
  41. [DEBUG] Configuring mojo com.liferay.maven.plugins:liferay-maven-plugin:6.1.0:deploy from plugin realm Cla***ealm[plugin>com.liferay.maven.plugins:liferay-maven-plugin:6.1.0, parent: sun.misc.Launcher$AppClassLoader@11b86e7] 
  42. [DEBUG] Configuring mojo 'com.liferay.maven.plugins:liferay-maven-plugin:6.1.0:deploy' with basic configurator --> 
  43. [DEBUG]   (f) autoDeployDir = D:\Liferay\RI\liferay-portal-6.1.0-ce-ga1\deploy 
  44. [DEBUG]   (f) warFile = D:\Charles\Eclipse_Workspace\charles-portlet\target\charles-portlet-0.0.1-SNAPSHOT.war 
  45. [DEBUG]   (f) warFileName = charles-portlet-0.0.1-SNAPSHOT.war 
  46. [DEBUG] -- end configuration -- 
  47. [INFO] Deploying charles-portlet-0.0.1-SNAPSHOT.war to D:\Liferay\RI\liferay-portal-6.1.0-ce-ga1\deploy 
  48. [INFO] ------------------------------------------------------------------------ 
  49. [INFO] BUILD SUCCESS 
  50. [INFO] ------------------------------------------------------------------------ 
  51. [INFO] Total time: 1:20.564s 
  52. [INFO] Finished at: Mon Jun 04 09:18:13 CST 2012 
  53. [INFO] Final Memory: 5M/11M 
  54. [INFO] ------------------------------------------------------------------------