在将我的 AWS 应用程序部署到 Elastic beanstalk 后,我收到 404 错误
注意项目在本地运行良好
我认为问题是,它无法找到我的 html 文件(这就是它抛出 404 的原因)。
这些是我采取的步骤
这就是我构建 .JAR 的方式
我在 Intellij 中单击了项目结构。这会打开这个窗口。 Window
然后我单击加号并从具有依赖项的模块中选择 JAR。这是开放的,这是我的选择。
最后这是它的样子,我相信它没有拿起我的资源文件夹,但是我不确定是否是这种情况
完成后我单击构建工件并将 .JAR 文件上传到 Amazon AWS Elastic BeanStalk What appears after JAR configuration is completed
但是一旦完成,我就会收到 404
HTTP Status 404 – Not Found
Type Status Report
Message The requested resource [/] is not available
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Apache Tomcat/8.5.63
这是我的控制器
@Controller
public class HomeController {
@RequestMapping("/")
public String index() throws IOException {
return "home";
}
@RequestMapping("/search-country")
public String login()
{
System.out.println("controller hit");
return "Search";
}
@RequestMapping(value = "/home-page",method = RequestMethod.POST)
public ModelAndView homepage(HttpServletRequest request) throws IOException {
ApiCaller apiCaller = new ApiCaller(request.getParameter("country_text"));
ModelAndView coronavirus = new ModelAndView("coronavirus");
coronavirus.addObject("country_flag_url",apiCaller.getFlagURL());
coronavirus.addObject("country_text","Cases for " + request.getParameter("country_text") + "as of " + Utils.todaysDate());
coronavirus.addObject("total_cases_text","Cumulative Cases: " + Utils.addCommasToNumericString(apiCaller.getTotalCases()));
coronavirus.addObject("deaths_today_text","Deaths today: " + Utils.addCommasToNumericString(apiCaller.getDeathsToday()));
coronavirus.addObject("cases_today_text","Cases today: " + Utils.addCommasToNumericString(apiCaller.getCasesToday()));
coronavirus.addObject("in_critical_care_text","In Intensive Care:" + Utils.addCommasToNumericString(apiCaller.getInCriticalCare()));
coronavirus.addObject("population_text","Total Population: " +Utils.addCommasToNumericString(apiCaller.getInCriticalCare()));
coronavirus.addObject("active_text","Active cases: " + Utils.addCommasToNumericString(apiCaller.getActiveCases()));
coronavirus.addObject("recovered_text","Recovered Cases" + Utils.addCommasToNumericString(apiCaller.getRecovered()));
coronavirus.addObject("deaths","Total deaths: " + Utils.addCommasToNumericString(apiCaller.getTotalCases()));
return coronavirus;
}
}