Multipart File Upload Issues with Jersey Restful API
In an effort to create a RESTful service for file uploads, you encountered the error: "No injection source found for a parameter of type public javax.ws.rs.core.Response." This error arises after attempting to run your Tomcat server.
Solution:
Your current dependencies include jersey-multipart-1.18.jar, which is meant for Jersey 1.x. For a successful build, replace it with these two JARs:
Additionally, register the MultiPartFeature class to your application. If using ResourceConfig, simply invoke:
1 |
|
For web.xml configuration, add the following as an init-param to the Jersey servlet:
1 2 3 4 |
|
After removing jersey-multipart-1.18.jar, you may encounter compile errors due to modified package names. Specifically, the following package names have changed:
Update your code accordingly, and your file upload service should operate as intended.
The above is the detailed content of How to Solve 'No injection source found' Errors in Jersey Multipart File Uploads?. For more information, please follow other related articles on the PHP Chinese website!