Skip to main content
 首页 » 编程设计

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

2025年12月25日27shanyou

我在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 

我该怎么做才能使这种依赖使Maven失败呢?

请您参考如下方法:

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

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”的存储库?