我是Maven的新手,我的问题是Maven不下载依赖项,而URL很好。确实,当我在浏览器中复制粘贴URL时,可以看到pom。
下面是我的pom.xml和Eclipse上mvn compile
的结果(运行--> maven build ...-> compile)
我的pom:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>groupId</groupId>
<artifactId>sourCode</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<repositories>
<repository>
<id>repo</id>
<name>repo ref</name>
<url>https://my.internalrepo/nexus/content/repositories/sdc1-releases</url>
</repository>
</repositories>
<name>sourCode</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>my.internal.package.package.to.download</groupId>
<artifactId>sourceCode</artifactId>
<version>3.0.4</version>
</dependency>
</dependencies>
</project>
编译结果:
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< groupId:sourCode >--------------------------
[INFO] Building sourCode 0.0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] Downloading from : https://my.internalrepo/nexus/content/repositories/sdc1-releases/my/internal/package/package/to/download/sourceCode/3.0.4/sourceCode-3.0.4.pom
[INFO] Downloading from : https://repo.maven.apache.org/maven2/my/internal/package/package/to/download/sourceCode/3.0.4/sourceCode-3.0.4.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.207 s
[INFO] Finished at: 2018-11-28T16:58:22+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project sourCode: Could not resolve dependencies for project groupId:sourCode:jar:0.0.1: Failed to collect dependencies at my.internal.package.package.to.download:sourceCode:jar:3.0.4: Failed to read artifact descriptor for my.internal.package.package.to.download:sourceCode:jar:3.0.4: Could not transfer artifact my.internal.package.package.to.download:sourceCode:pom:3.0.4 from/to repo (https://my.internalrepo/nexus/content/repositories/sdc1-releases): handshake alert: unrecognized_name -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[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 read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
当我复制粘贴“ https://my.internalrepo/nexus/content/repositories/sdc1-releases/my/internal/package/package/to/download/sourceCode/3.0.4/sourceCode-3.0.4.pom”时,我可以看到pom
我试图在终端中使用“ mvn compile”进行编译,结果:
Caused by: java.net.UnknownHostException: my.internalrepo: unknown name or service
有什么办法解决这个问题吗?
编辑:当我尝试编译时,当我连接到Internet(URL不可用)和我在本地网络上时,是有区别的:
在Internet上:
Could not resolve dependencies for project [...]: my.internalrepo: Unknown host my.internalrepo -> [Help 1]
在本地网络上:
Could not resolve dependencies for project [...]: handshake alert: unrecognized_name -> [Help 1]
EDIT2:我尝试通过wget下载sourceCode-3.0.4.pom,如果我使用“ --no-check-certificate”,则可以