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;
} }
Locally I used
mvn spring-boot:run
That's why I had no problem with my web service
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.