如何通过Maven构建项目时解决一些依赖问题?

3

我有一些Java项目,正在尝试在Windows上使用Maven构建它。但是在此过程中出现了某些错误。我已经使用以下命令:

"mvn -Dmaven.test.skip=true install" 

细节如下:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] OpenEMPI Application .............................. SUCCESS [1.610s]
[INFO] OpenEMPI - Core ................................... SUCCESS [1:39.281s]
[INFO] OpenEMPI - OpenPIXPDQ Adapter ..................... FAILURE [48.469s]
[INFO] OpenEMPI - EJB Interface .......................... SKIPPED
[INFO] OpenEMPI - Web (Struts 2) ......................... SKIPPED
[INFO] OpenEMPI - Web (Server Side) ...................... SKIPPED
[INFO] OpenEMPI - Web (Client Side) ...................... SKIPPED
[INFO] OpenEMPI - EAR .................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:31.203s
[INFO] Finished at: Fri Jun 08 04:30:04 CDT 2012
[INFO] Final Memory: 11M/60M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project openempi-openpixpdq-adapter: Could not
 resolve dependencies for project org.openhie.openempi:openempi-openpixpdq-adapt
er:jar:2.0.5: Failed to collect dependencies for [javax.ejb:ejb-api:jar:3.0 (pro
vided), org.openhie.openempi:openempi-core:jar:2.0.5 (compile), org.openhealthex
change.openpixpdq:openpixpdq:jar:1.1 (compile), com.misys.braid:braid-base:jar:1
.2.2 (compile), com.misys.hieportal.sysmon:eventmonitoring:jar:1.0 (compile), ca
.uhn.hapi:hapi:jar:0.5.1 (compile), commons-dbcp:commons-dbcp:jar:1.2.1 (compile
), commons-beanutils:commons-beanutils:jar:1.8.0 (compile), commons-collections:
commons-collections:jar:3.2 (compile), commons-lang:commons-lang:jar:2.3 (compil
e), javax.mail:mail:jar:1.4 (compile), javax.persistence:persistence-api:jar:1.0
 (compile), net.sf.ehcache:ehcache:jar:1.4.1 (compile), org.aspectj:aspectjweave
r:jar:1.6.0 (compile), org.aspectj:aspectjrt:jar:1.6.0 (compile), org.codehaus.x
fire:xfire-java5:jar:1.2.6 (compile), org.codehaus.xfire:xfire-spring:jar:1.2.6
(compile), org.hibernate:hibernate:jar:3.2.6.ga (compile), org.hibernate:hiberna
te-annotations:jar:3.3.0.ga (compile), org.hibernate:hibernate-commons-annotatio
ns:jar:3.3.0.ga (compile), org.jmock:jmock:jar:2.4.0 (compile?), org.jmock:jmock
-junit4:jar:2.4.0 (compile?), org.springframework:spring-jdbc:jar:2.5.4 (compile
), org.springframework:spring-orm:jar:2.5.4 (compile), org.springframework:sprin
g-aop:jar:2.5.4 (compile), org.springframework:spring-aspects:jar:2.5.4 (compile
), org.springframework:spring-context-support:jar:2.5.4 (compile), org.jboss.cli
ent:jbossall-client:jar:4.2.3.GA (test), org.jboss:jnp-client:jar:4.2.2.GA (test
), org.subethamail:subethasmtp-wiser:jar:1.2 (test), velocity:velocity:jar:1.4 (
compile), postgresql:postgresql:jar:8.1-407.jdbc3 (compile), junit:junit:jar:4.4
 (compile?), log4j:log4j:jar:1.2.15 (compile), org.springframework:spring-test:j
ar:2.5.4 (compile?), org.springframework.security:spring-security-core-tiger:jar
:2.0.1 (compile), javax.annotation:jsr250-api:jar:1.0 (compile)]: Failed to read
 artifact descriptor for org.openhealthexchange.openpixpdq:openpixpdq:jar:1.1: C
ould not transfer artifact org.openhealthexchange.openpixpdq:openpixpdq:pom:1.1
from/to central (http://repo1.maven.org/maven2): Connection to http://repo1.mave
n.org refused: Connection timed out: connect -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyReso
lutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command

[ERROR]   mvn <goals> -rf :openempi-openpixpdq-adapter

我想请问如何解决依赖关系问题,因为我遇到了特定的问题。我对Maven并不是很了解,所以陷入了这样的困境。

请给予建议。

谢谢


2
OT:你应该优先选择-DskipTests而不是-Dmaven.test.skip,因为前者总是会构建测试类但跳过运行它们,而后者甚至不会构建它们。通过这样做,你可以确保构建是正确的。而且可能会有人使用需要更新的测试工件。请参阅此链接 - maba
1
@maba:我尝试使用您指定的选项“-DskipTests”,但结果仍然相同。 :( - Bhavesh Shah
1
当然可以。我没有发布解决方案,只是提供了其他帮助,因此有点偏题了。 - maba
3个回答

6

3
此外,���Central下载�件,�试建立自己的“�业存储库�。
  • 这将å‡�è½»æœ�务器的负担。
  • 这将å‡�è½»ä¼�业互è�”网带宽的负担(我的é��常有é™�😉)。
  • 您将æˆ�功部署自己的æ�„件。

您�需�一个�务器(物�或虚拟)和Tomcat��。您应该阅读此�费书�:http://www.sonatype.com/books/mvnref-book/reference/

主�产�有:

虽然你�能�是想安装Maven,�好你的POM并继续,但这并�难,�是有点烦人。


1
xxx xxx .... from/to central (http://repo1.maven.org/maven2):
    Connection to http://repo1.maven.org refused: Connection timed out: connect ->

看起来当Maven尝试从其存储库下载依赖项时,无法建立连接。有几个选项:

  1. 确保您的互联网连接可用
  2. 不要使用-o开关运行安装
  3. 配置Maven代理设置(http://maven.apache.org/guides/mini/guide-proxies.html
  4. 有时需要从特定存储库下载某些依赖项(例如,从jboss存储库下载jboss依赖项),因此可能需要将特定存储库添加到pom中

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接