向我的pom添加依赖项会使其崩溃

时间:2013-07-15 06:10:27

标签: maven crash dependencies

我在Eclipse中使用maven作为项目的maven测试,我有下一个pom

<?xml version="1.0" encoding="UTF-8"?>
<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>com.co.misterfish</groupId>
<artifactId>misterfishLogico</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>mister fish</name>
<dependencies>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.25</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.5</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.ejb</artifactId>
        <version>3.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>javax.persistence</artifactId>
        <version>2.1.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>eclipselink</artifactId>
        <version>2.5.0</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.main.extras</groupId>
        <artifactId>glassfish-embedded-all</artifactId>
        <version>4.0</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <inherited>true</inherited>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.2</version>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.2</version>
            <executions>
                <execution>
                    <goals>
                        <goal>test-jar</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
                <archive>
                    <manifest>
                        <mainClass>com.co.misterfish.aplication.ejb.UserEJB</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.glassfish</groupId>
            <artifactId>maven-embedded-glassfish-plugin</artifactId>
            <version>3.1</version>
        </plugin>
    </plugins>
</build>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
</project>

当我将下一个依赖项添加到我的pom

<dependency>
  <groupId>org.glassfish.appclient</groupId>
  <artifactId>gf-client</artifactId>
  <version>3.2-b06</version>
</dependency>

我收到此错误消息,并且我尝试使用不同版本的appclient,但所有版本都有相同的错误

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building mister fish 1.0
[INFO] ------------------------------------------------------------------------
Downloading: (... lot of links...)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22.118s
[INFO] Finished at: Mon Jul 15 00:59:34 COT 2013
[INFO] Final Memory: 12M/28M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project misterfishLogico: Could not resolve dependencies for project com.co.misterfish:misterfishLogico:war:1.0: Failed to collect dependencies for [mysql:mysql-connector-java:jar:5.1.25 (test), org.glassfish.appclient:gf-client:jar:3.2-b06 (compile), junit:junit:jar:4.5 (test), org.glassfish:javax.ejb:jar:3.1 (provided), org.eclipse.persistence:javax.persistence:jar:2.1.0 (provided), org.eclipse.persistence:eclipselink:jar:2.5.0 (compile), org.glassfish.main.extras:glassfish-embedded-all:jar:4.0 (test)]: Failed to read artifact descriptor for org.eclipse.persistence:javax.persistence:jar:2.0.3: Could not transfer artifact org.eclipse.persistence:javax.persistence:pom:2.0.3 from/to glassfish-repo-archive (http://maven.glassfish.org/content/groups/glassfish): hostname in certificate didn't match: <maven.glassfish.org> != <maven.java.net> OR <maven.java.net> -> [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

如何添加此依赖关系whitout,使maven失败?

2 个答案:

答案 0 :(得分:0)

我认为这部分错误是问题所在:

Could not transfer artifact org.eclipse.persistence:javax.persistence:pom:2.0.3 
  from/to glassfish-repo-archive (http://maven.glassfish.org/content/groups/glassfish):
  hostname in certificate didn't match: <maven.glassfish.org> != <maven.java.net> OR <maven.java.net> -> [Help 1]
[ERROR] 

您是否在Maven设置文件中配置了名为“glassfish-repo-archive”的存储库?

答案 1 :(得分:0)

我对maven很新,如果我错了,请纠正我。 我遇到了同样的问题,并以两种方式解决了问题:

在POM中添加以下两个存储库:

<repositories>
    <repository>  
        <url>i</url>  
        <id>eclipselink</id>  
        <layout>default</layout>  
        <name>Repository for library Library[eclipselink]</name>  
    </repository> 
    <repository>
        <id>glassfish-repo-archive</id>
        <name>glassfish-repo-archive</name>
        <url>https://maven.java.net/content/groups/public/</url>
    </repository>
</repositories>

第一个存储库是必要的,因为有一些依赖关系(参见this post),而第二个存储库是gf-client(在某些地方指向glassfish-repos-archive)。

或使用其他套餐:

<dependency>
    <groupId>org.glassfish.main.appclient</groupId>
    <artifactId>gf-client</artifactId>
    <version>4.0</version>
    <scope>test</scope>
</dependency>

我使用的是org.glassfish.appclient:org.glassfish。 main .appclient

此解决方案的问题在于您(目前 - - 8月23日)只能看到版本4.0,因此如果您需要不同版本,则可以尝试第一个解决方案。

相关问题