我需要一个REST服务来处理文件上传。我添加了 RESTEasy Multipart Provider 依赖项:
<!-- https://mvnrepository.com/artifact/org.jboss.resteasy/resteasy-multipart-provider -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-multipart-provider</artifactId>
<version>3.1.4.Final</version>
</dependency>
这导致我的其他REST服务无法正常工作,现在它们会返回错误:
<html>
<head>
<title>Error</title>
</head>
<body>Not Found</body>
</html>
或
<html>
<head>
<title>Error</title>
</head>
<body>HTTP method POST is not supported by this URL</body>
</html>
我读到这是因为缺少doGet()和doPost()的实现。 我不明白如何简单地添加此依赖项会影响我的其他Web服务。它是否添加了新的Servlet?
这是我的Web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.1"
xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<display-name>my_project</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<filter>
<filter-name>CORS</filter-name>
<filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class>
<init-param>
<param-name>cors.allowGenericHttpRequests</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>cors.allowOrigin</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.allowSubdomains</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>cors.supportedMethods</param-name>
<param-value>GET, HEAD, POST, DELETE, OPTIONS, PUT</param-value>
</init-param>
<init-param>
<param-name>cors.supportedHeaders</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.exposedHeaders</param-name>
<param-value>Authorization, next-jwt-token</param-value>
</init-param>
<init-param>
<param-name>cors.supportsCredentials</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>cors.maxAge</param-name>
<param-value>3600</param-value>
</init-param>
</filter>
<filter-mapping>
<!-- CORS Filter mapping -->
<filter-name>CORS</filter-name>
<url-pattern>*</url-pattern>
</filter-mapping>
</web-app>
答案 0 :(得分:2)
依赖的版本不是我的野生动物使用的版本。我通过将版本更改为正确的(3.0.24.Final,随WildFly 11 Final发布)解决了我的问题,并将范围更改为提供:
<!-- Resteasy-multipart-provider -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-multipart-provider</artifactId>
<version>3.0.24.Final</version>
<scope>provided</scope>
</dependency>