- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在开发一个基于 Jersey 的 Java (1.8) 动态 Web 应用程序,并使用 Maven 定义依赖项。我正在使用 Tomcat 9 在 Eclipse Oxygen 中工作。我在 Web 应用程序开发和 Maven 方面都是新手,所以我很难理解如何让事情正常工作。
当我运行该应用程序时,它失败并出现如下错误。我读过几篇文章。这个错误显然是由于编译时环境和运行时环境不匹配造成的。
我尝试过更改各种组件的版本,希望找到正确的组合,但没有成功。我还尝试删除 .m2/repository 并运行 Maven/Update Project 来刷新环境,但这没有帮助。也许有更多经验的人可以在我的 pom.xml 文件中发现不兼容的根源。
java.lang.NoSuchMethodError: javax.ws.rs.core.MultivaluedMap.addAll(Ljava/lang/Object;[Ljava/lang/Object;)V
at org.glassfish.jersey.client.ClientRequest.accept(ClientRequest.java:335)
at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:222)
at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:60)
at com.simfinit.client.SimDcmClient.get(SimDcmClient.java:36)
at com.simfinit.client.SimDcmClientTest.testGetList(SimDcmClientTest.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
这是我的 pom.xml 文件:
<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>com.simfinit.resources</groupId>
<artifactId>SimWebServiceDcm</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>SimWebServiceDcm</name>
<build>
<finalName>SimWebServiceDcm</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<inherited>true</inherited>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- artifactId>jersey-container-servlet</artifactId -->
</dependency>
<!-- uncomment this to get JSON support -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>8.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>${jersey.version}</version>
</dependency>
<!-- <dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>${jersey.version}</version>
</dependency>
-->
<dependency>
<groupId>com.simfinit</groupId>
<artifactId>SimService</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.simfinit</groupId>
<artifactId>SimCommunication</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.simfinit</groupId>
<artifactId>SimServiceDcm</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.simfinit</groupId>
<artifactId>SimBase</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
<properties>
<jersey.version>2.26</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
我尝试使用“mvn dependency:tree”来识别可能的冲突。此命令返回错误:
[ERROR] No plugin found for prefix 'dependency' in the current project and in the plugin groups...
我阅读了帮助文章和其他文章,建议删除 .m2/repository 文件夹并重复 mvn 命令。结果如下所示。这些错误是否表明我在 pom 文件中提供了不正确的版本号?我想这些信息应该对我有帮助,但我不知道下一步应该做什么。我的pom内容来自其他文章,但可能只对某些版本有效。我一直在添加和替换 pom 依赖项,但并不真正知道如何确定更改的兼容性。
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.758 s
[INFO] Finished at: 2018-05-17T14:56:56-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'help' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\Users\Kent\.m2\repository), central (https://repo.maven.apache.org/maven2)] -> [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/NoPluginFoundForPrefixException
E:\GitRepositories\simfiniclient\SimWebServiceDcm>mvn help:active-profiles
[INFO] Scanning for projects...
Downloading from central: https://repo.maven.apache.org/maven2/org/glassfish/jersey/jersey-bom/2.26/jersey-bom-2.26.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Non-resolvable import POM: Could not transfer artifact org.glassfish.jersey:jersey-bom:pom:2.26 from/to central (https://repo.maven.apache.org/maven2): Permission denied: connect @ line 31, column 16
[ERROR] 'dependencies.dependency.version' for org.glassfish.jersey.containers:jersey-container-servlet-core:jar is missing. @ line 47, column 15
[ERROR] 'dependencies.dependency.version' for org.glassfish.jersey.media:jersey-media-moxy:jar is missing. @ line 54, column 15
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.simfinit.resources:SimWebServiceDcm:1.0-SNAPSHOT (E:\GitRepositories\simfiniclient\SimWebServiceDcm\pom.xml) has 3 errors
[ERROR] Non-resolvable import POM: Could not transfer artifact org.glassfish.jersey:jersey-bom:pom:2.26 from/to central (https://repo.maven.apache.org/maven2): Permission denied: connect @ line 31, column 16 -> [Help 2]
[ERROR] 'dependencies.dependency.version' for org.glassfish.jersey.containers:jersey-container-servlet-core:jar is missing. @ line 47, column 15
[ERROR] 'dependencies.dependency.version' for org.glassfish.jersey.media:jersey-media-moxy:jar is missing. @ line 54, column 15
[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/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
最佳答案
这个错误确实是由于编译时和运行时依赖版本不匹配造成的,但可能不完全是maven这边的。
首先:执行 mvn dependency:tree
并查找 jax-ws。如果您发现多个具有不同版本的版本:使用 exclude option 在 pom 中排除它们.
如果你没有找到任何东西或者没有帮助:检查你的 tomcat 安装和配置(像 libs 这样的文件夹或者在启动过程中是否添加了任何额外的 jar)。有一次我在使用 Guava 时遇到这样的问题,我使用的是 23.0,而我的应用程序服务器使用的是 12.0,并且它的优先级高于我的。
如果它不能帮助检查您的 JDK 和 endorsed
文件夹,也许您那里有额外的东西。
从未使用过最新版本的 JavaEE 和 Tomcat,但也许通用解决方案会有所帮助。
关于java - NoSuchMethodError : javax. ws.rs.core.MultivaluedMap.addAll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50400251/
来自 JSR-339: For simplicity, JAX-RS implementations are NOT REQUIRED to support processing groups oth
JAX-RS 提供了 StreamingOutput 接口(interface),我们可以实现它来对我们的响应主体进行原始流处理。 public interface StreamingOutput {
有没有办法获得java.lang.reflect.Method为给定的 @Path 调用的方法(用 HttpServletRequest 注释) ? 这是我的用例:我在 Java EE 中 Filte
我接到了一家公司的任务,该任务向我发送了一台已完成所有设置的虚拟机。任务是我必须创建一个 API 来从数据库中检索人员详细信息并显示它。 问题是,当我运行应用程序时,服务器返回一个包含 hello w
我有一个 POST 方法调用,它接受很少的表单参数。我希望 JAX-RS 能够处理不存在特定表单参数的情况。 示例: @POST @Produces (MediaType.APPLICATION_JS
我有 JAX-RS 网络应用程序,我想记录从获取请求到响应的时间量。在带有 servlet 过滤器的 Spring Boot 中很容易。但是我的应用程序中的过滤器无法正常工作: @Provider p
使用以下网址。 http://doma.in/context/resource/some/.../undefined 我想获取 ../resource 之后的路径名,即 /some/.../undef
Closed. This question is off-topic。它当前不接受答案。
我花了几个小时在嵌入式 Jetty 9.1.0.v20131115 和 RESTEasy 3.0.5.Final 中安装自定义登录服务。我的登录服务将在数据库中查找用户并为他们分配角色。它看起来像这样
RESOURCE_STALLS.RS的说明Intel Broadwell 的硬件性能事件如下: This event counts stall cycles caused by absence of
我想从 java 服务器 (Restful Jax-rs) 发送图像。我的客户是安卓。 @GET public Response getUserImage() { byte[] image =new
(特别是 RESTeasy) 具有如下方法签名会很好(对于单个文件): public void upload(@FormParam("name") ..., @FormParam("file") fi
RESTEasy (JAX-RS) 允许通过子资源进行动态调度。例如: POST /customers/create {"name":"Smith","country":"jp"} 我们可以有一个根资
假设有一个 ResultSet rs 和 n 对象。 这段代码: while(rs.next()) { // do something on rs } 在算法上等于此代码(即两者给出相同的结果)
我正在使用 Visual Studio 2005 和 mysql 4.0,我有一个表,其中包含一个字段(十进制 16,4),用于存储发票金额和另一个表,其中包含对该发票的付款(这些字段也是十进制的)
我正在使用 JAX-RS、Microprofile 和 Payara 5 构建 REST 服务。我的方法返回类型为 Response 的对象。响应本身包含一个 MyClass 列表。实现看起来像这样:
我已经使用 Mock MVC 成功地为 Spring MVC REST 服务构建了无需部署的集成测试框架。我正在努力对 JAX-RS 服务做同样的事情。 REST Assured 看起来很有希望,但它
我有一个使用JAX-RS 2.0的Jersey实现的Java应用程序,并且我想在客户端启用gzip压缩。服务器已启用它,并且通过在Chrome中的开发人员工具中的“大小/内容”中查找客户端正在使用的特
我正在尝试与 Tomcat7 一起使用 RESTful Web 服务 (JAX-RS)。我尝试了 3 种不同的实现(Jersey、RESTeasy 和 ReSTLet),但都没有成功。这应该很容易,但
swagger-api有什么区别和 JAX-RS ? 是swagger-api仅用于文档? (例如 @ApiOperation ) 最佳答案 根据 API 文档,JAX-RS是用于 RESTful W
我是一名优秀的程序员,十分优秀!