简体   繁体   中英

Web service stopped working after deploy

It works locally on localhost. Tried to deploy on Heroku and AWS. Doesn't work. But static resources are ok. Response is 404.

@SpringBootApplication
@RestController
public class WebService implements WebServiceInterface{

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

    @Override
    @RequestMapping("/getcontent")
    public WebContent getContent(@RequestParam(value="id", defaultValue="summary") String id) {
        try {
            return new WebContent(id);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    } }
  1. Locally I used

    mvn spring-boot:run

That's why I had no problem with my web service

  1. For Heroku and AWS I deployed war package. It didn't work for my code. Only this initializer helped to solve my problem:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM