[maven 问题]java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map...

NotifyService站点今天maven build的时候出现如下异常

WARNING] FAILED org.eclipse.jetty.maven.plugin.JettyServer@3c64339f: java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
    at org.glassfish.jersey.server.ApplicationHandler. (ApplicationHandler.java:331)
    at org.glassfish.jersey.servlet.WebComponent. (WebComponent.java:390)
    at org.glassfish.jersey.servlet.ServletContainer.init (ServletContainer.java:172)
    at org.glassfish.jersey.servlet.ServletContainer.init (ServletContainer.java:364)
    at javax.servlet.GenericServlet.init (GenericServlet.java:244)
    at org.eclipse.jetty.servlet.ServletHolder.initServlet (ServletHolder.java:616)
    at org.eclipse.jetty.servlet.ServletHolder.initialize (ServletHolder.java:396)
    at org.eclipse.jetty.servlet.ServletHandler.initialize (ServletHandler.java:871)
    at org.eclipse.jetty.servlet.ServletContextHandler.startContext (ServletContextHandler.java:298)
    at org.eclipse.jetty.webapp.WebAppContext.startWebapp (WebAppContext.java:1349)
    at org.eclipse.jetty.maven.plugin.JettyWebAppContext.startWebapp (JettyWebAppContext.java:297)
    at org.eclipse.jetty.webapp.WebAppContext.startContext (WebAppContext.java:1342)
    at org.eclipse.jetty.server.handler.ContextHandler.doStart (ContextHandler.java:741)
    at org.eclipse.jetty.webapp.WebAppContext.doStart (WebAppContext.java:505)
    at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart (JettyWebAppContext.java:366)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:132)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:114)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:61)
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart (ContextHandlerCollection.java:163)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:132)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:114)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:61)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:68)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.start (ContainerLifeCycle.java:132)
    at org.eclipse.jetty.server.Server.start (Server.java:387)
    at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart (ContainerLifeCycle.java:114)
    at org.eclipse.jetty.server.handler.AbstractHandler.doStart (AbstractHandler.java:61)
    at org.eclipse.jetty.server.Server.doStart (Server.java:354)
    at org.eclipse.jetty.maven.plugin.JettyServer.doStart (JettyServer.java:73)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start (AbstractLifeCycle.java:68)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty (AbstractJettyMojo.java:535)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute (AbstractJettyMojo.java:358)
    at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute (JettyRunMojo.java:167)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:290)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:194)
    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:498)
    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)
[INFO] Jetty server exiting.

这种错误通常意味着您在类路径上同时具有JAX-RS 1和JAX-RS 2 jar.Jersey2使用JAX-RS 2(javax.ws.rs-api-2.0.1.jar),但是如果你还有jsr311-api.jar,那就是JAX-RS 1,有一个javax.ws.rs .core.Application在每个jar.但是jsr311-api应用程序没有getProperties()方法(因此NoSuchMethodError).

mvn dependency:tree -Doutput=tree.txt 导出依赖关系如下:

[maven 问题]java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map..._第1张图片

[maven 问题]java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map..._第2张图片

确实同时存在二个版本的javax.ws.rs-api。exclude之后重新build,OK。

转载于:https://www.cnblogs.com/zhengwangzw/p/10552833.html

你可能感兴趣的:([maven 问题]java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map...)