将Jersey从1.x迁移到2.x时编译错误

时间:2016-01-11 22:11:34

标签: java maven jersey pom.xml jersey-2.0

我的pom文件包含:

<dependency>
  <groupId>org.glassfish.jersey.core</groupId>
  <artifactId>jersey-client</artifactId>
  <version>2.22.1</version>
</dependency>
<dependency>
  <groupId>org.glassfish.jersey.core</groupId>
  <artifactId>jersey-server</artifactId>
  <version>2.22.1</version>
</dependency>
<dependency>
  <groupId>org.glassfish.jersey.core</groupId>
  <artifactId>jersey-common</artifactId>
  <version>2.22.1</version>
</dependency>
<dependency>
  <groupId>org.glassfish.jersey.media</groupId>
  <artifactId>jersey-media-json-jettison</artifactId>
  <version>2.21.1</version>
</dependency>

日志中显示的错误: 更新错误:

[INFO] --- maven-dependency-plugin:2.10:analyze-only (analyze) @ 
 api-services ---
[WARNING] Unused declared dependencies found:
[WARNING]    org.glassfish.jersey.core:jersey-client:jar:2.22.1:compile
[WARNING]    org.glassfish.jersey.core:jersey-common:jar:2.22.1:compile
[WARNING]    org.glassfish.jersey.core:jersey-server:jar:2.22.1:compile
[WARNING]    org.glassfish.jersey.media:jersey-media-jaxb:jar:2.22.1:compile
[WARNING]    org.glassfish.jersey.media:jersey-media-json-
   jackson:jar:2.22.1:compile
Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.10:analyze-only (analyze) on project api-services: Dependency problems found -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.10:analyze-only (analyze) on project api-services: Dependency problems found
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Dependency problems found
    at org.apache.maven.plugin.dependency.analyze.AbstractAnalyzeMojo.execute(AbstractAnalyzeMojo.java:260)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)

更新 删除上述依赖项后,我设法构建了我的项目。 所以看起来上面的一个需要其他依赖项。有什么想法吗?

更新1: 这就是分析的定义方式

      <execution>
        <phase>package</phase>
        <goals>
          <goal>analyse</goal>
        </goals>
      </execution>

1 个答案:

答案 0 :(得分:0)

所以我们确实有一个分析pom的目​​标(我们在父pom上有它)。这个分析只是确保我们不会在儿子pom中声明重复的东西。 一旦我删除了重复项,一切都是构建的。 顺便说一句:通过取消这个目标,我也将取得成功。