0

我在 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 失败?

4

2 回答 2

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

于 2013-07-15T21:47:03.937 回答
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>

第一个存储库是必需的,因为存在一些依赖关系(请参阅这篇文章),而第二个存储库用于 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.appclient。.appclient

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

于 2013-08-23T10:05:21.090 回答