在glasfish中访问spring boot REST服务

时间:2016-11-08 08:10:34

标签: java spring rest spring-boot glassfish-4.1

做了以下教程https://spring.io/guides/gs/uploading-files/ 现在我希望能够将其部署到glassfish 4.1。问题是我无法进入暴露的休息服务

我的申请类:

package de.awinta.kti.cms;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;

@SpringBootApplication
public class Application extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }


}

我的休息室:

@RestController
@RequestMapping("/files")
public class FileUploadController {

    //private final StorageService storageService;

    @Autowired
    public FileUploadController() {
       // this.storageService = storageService;
    }

    @RequestMapping("/upload")
    public String handleFileUpload(@RequestParam("file") MultipartFile file,
                                   RedirectAttributes redirectAttributes) {

        //storageService.store(file);
        //redirectAttributes.addFlashAttribute("message",
          //      "You successfully uploaded " + file.getOriginalFilename() + "!");

        System.out.println("File uplaoded succesfully");

        return "asda";
    }

    @ExceptionHandler(Exception.class)
    public ResponseEntity handleStorageFileNotFound(Exception exc) {
        return ResponseEntity.notFound().build();
    }

}

有什么想法吗?

0 个答案:

没有答案