使用Jersey测试框架的Maven构建错误

时间:2022-07-02 19:36:08

I'm currently working on a simple Java REST Service that must be deployed on Heroku. I need to do some tests, so i try to integrate Jersey test framework to my web service.

我目前正在开发一个必须部署在Heroku上的简单Java REST服务。我需要做一些测试,所以我尝试将Jersey测试框架集成到我的Web服务中。

But when i run mvn clean install, i keep getting a build error. I already searched it, but at this point, i'm clueless.

但是当我运行mvn clean install时,我不断收到构建错误。我已经搜索过了,但此时此刻,我一无所知。


Here is it (with mvn -e clean install) :

这是它(使用mvn -e clean install):

[INFO] ------------------------------------------------------------------------                                                         
[ERROR] BUILD ERROR                                                                                                                     
[INFO] ------------------------------------------------------------------------                                                         
[INFO] Error building POM (may not be this project's POM).                                                                              


Project ID: null:jetty-project:pom:9.1.1.v20140108                                                                                      

Reason: Cannot find parent: org.eclipse.jetty:jetty-parent for project: null:jetty-project:pom:9.1.1.v20140108 for project null:jetty-project:pom:9.1.1.v20140108                                                                                                               


[INFO] ------------------------------------------------------------------------                                                         
[INFO] Trace                                                                                                                            
org.apache.maven.lifecycle.LifecycleExecutionException: Unable to get dependency information: Unable to read the metadata file for artifact 'org.eclipse.jetty:jetty-server:jar': Cannot find parent: org.eclipse.jetty:jetty-parent for project: null:jetty-project:pom:9.1.1.v20140108 for project null:jetty-project:pom:9.1.1.v20140108                                                                             
  org.eclipse.jetty:jetty-server:jar:9.1.1.v20140108

Edit : And here is my pom.xml :

编辑:这是我的pom.xml:

<?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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>fr.mycompagny.stockservice</groupId>
  <version>1.0-SNAPSHOT</version>
  <artifactId>StockService</artifactId>
  <dependencies>
    <dependency>
        <groupId>org.glassfish.jersey.containers</groupId>
        <artifactId>jersey-container-servlet</artifactId>
        <version>2.17</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-servlet</artifactId>
        <version>9.2.10.v20150310</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-webapp</artifactId>
        <version>9.2.10.v20150310</version>
    </dependency>

    <dependency>
      <groupId>javax.ws.rs</groupId>
      <artifactId>javax.ws.rs-api</artifactId>
      <version>2.0.1</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.hibernate.ogm</groupId>
        <artifactId>hibernate-ogm-mongodb</artifactId>
        <version>4.1.3.Final</version>
    </dependency>

    <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-json-jackson</artifactId>
        <version>2.17</version>
    </dependency>

    <dependency>
    <groupId>javax.persistence</groupId>
    <artifactId>persistence-api</artifactId>
    <version>1.0.2</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.persistence</groupId>
      <artifactId>eclipselink</artifactId>
      <version>2.5.2</version>
    </dependency>
    <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
      <version>2.6</version>
      <type>jar</type>
    </dependency>

    <dependency>
    <groupId>org.glassfish.jersey.test-framework.providers</groupId>
    <artifactId>jersey-test-framework-provider-jetty</artifactId>
    <version>2.17</version>
    </dependency>

  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>2.4</version>
        <executions>
          <execution>
            <id>copy-dependencies</id>
            <phase>package</phase>
            <goals><goal>copy-dependencies</goal></goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
    <properties>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
    </properties>
</project>

What i am doing wrong ? Could it be because of the jetty server Heroku uses ?

我做错了什么?可能是因为Heroku使用的码头服务器?

Best regards.

1 个解决方案

#1


(As suggested in the comment by @Yoluk, I'm posting my comment as an answer)

(根据@Yoluk的评论中的建议,我发表评论作为答案)

I was having this issue (while trying to compile java-asana) and solved by using the last apache-maven version, 3.3.3 right now (was getting the error with 2.2.1).

我遇到了这个问题(在尝试编译java-asana时),并且现在使用最后一个apache-maven版本3.3.3解决了(正在使用2.2.1获得错误)。

#1


(As suggested in the comment by @Yoluk, I'm posting my comment as an answer)

(根据@Yoluk的评论中的建议,我发表评论作为答案)

I was having this issue (while trying to compile java-asana) and solved by using the last apache-maven version, 3.3.3 right now (was getting the error with 2.2.1).

我遇到了这个问题(在尝试编译java-asana时),并且现在使用最后一个apache-maven版本3.3.3解决了(正在使用2.2.1获得错误)。