MULTIPART_FORM_DATA: No injection source found for a parameter of type public javax.ws.rs.core.Response

后端 未结 8 1500
难免孤独
难免孤独 2020-11-22 08:52

I am using Jersey based restful Service implementation strategy to build a service which will be used to upload files. My service class name is : UploadFileService.java (See

8条回答
  •  情话喂你
    2020-11-22 09:36

    Below code worked for me:

    Class ->>> add it

    Class Property --->> add it


    Public Class userREST () {

    @POST
        @Path("upload")
        @Consumes(MediaType.MULTIPART_FORM_DATA)
        @Produces(MediaType.APPLICATION_JSON)
        public Response uploadImageFile(@FormDataParam("uploadFile") InputStream fileInputStream,
                @FormDataParam("uploadFile") FormDataContentDisposition fileFormDataContentDisposition,
                @FormDataParam("FIR_REG_NUM") String FIR_REG_NUM, @FormDataParam("LOGIN_ID") String LOGIN_ID) {
    
            final_json_result = WriteFileInFolder.fileAnalysis(fileInputStream, fileFormDataContentDisposition, FIR_REG_NUM,
                    LOGIN_ID);
    
            return Response.ok(final_json_result).build();
    
        }// uploadImageFile
    

    Public Class FileJAXRSConfig () {

    package ####.jaxrs.jwt;
    
    import java.util.HashMap;
    import java.util.HashSet;
    import java.util.Map;
    import java.util.Set;
    import javax.ws.rs.ApplicationPath;
    import javax.ws.rs.core.Application;
    
    import ####.helper.Common@@@;
    import ####.jaxrs.jwt.filters.JWTRequestFilter;
    import ####.jaxrs.jwt.filters.JWTResponseFilter;
    import ####.service.FileServicesREST;
    
    
    
    @ApplicationPath("fileservice")
    public class FileJAXRSConfig extends Application {
    
        @Override
        public Set> getClasses() {
    
            Common@@@.logging("@ApplicationPath@FileServicesREST...");
            Set> clazzes = new HashSet>();
            clazzes.add(JWTRequestFilter.class);
            clazzes.add(FileServicesREST.class);
            clazzes.add(JWTResponseFilter.class);
    
            return clazzes;
        }
    
    
        @Override
        public Map getProperties() {
            Map properties = new HashMap();
            properties.put("jersey.config.server.provider.packages", "####.service");
            properties.put("jersey.config.server.provider.classnames", "org.glassfish.jersey.media.multipart.MultiPartFeature");
            return properties;
        }
    
    }
    

    Don't need to add following in web.xml

    
                jersey.config.server.provider.packages
                mha.@@@.service
            
            
                jersey.config.server.provider.classnames
                org.glassfish.jersey.media.multipart.MultiPartFeature
            
    

提交回复
热议问题