当我们使用搭建一个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] ------------------------------------------------------------------------