且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

尝试访问Amazon Elastic Bean Stalk上的Spring Boot应用程序时出现错误404

更新时间:2023-01-09 23:17:03

解决方案1:

如果要在可执行Jar中使用JSP进行Spring Boot

请记住,我们最终会将JSP模板放在src/main/resources/META-INF/resources/WEB-INF/jsp/

Keep in mind that we will ultimately place the JSP templates under src/main/resources/META-INF/resources/WEB-INF/jsp/

注意: 在application.properties中为我们的JSP文件定义模板前缀和后缀

Note : define the template prefix and suffix for our JSP files in application.properties

spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp

然后您可以使用以下命令运行jar文件:

Then your can run jar file using below command :

java -jar <your jar name>

 for your project you can below command

   java -jar  auth-1.3.5.RELEASE.jar

更多参考信息: https://dzone .com/articles/spring-boot-with-jsps-in-executable-jars-1

解决方案2:

JSP限制

在运行使用嵌入式servlet容器(并打包为可执行归档文件)的Spring Boot应用程序时,JSP支持存在一些限制.

When running a Spring Boot application that uses an embedded servlet container (and is packaged as an executable archive), there are some limitations in the JSP support.

对于Jetty和Tomcat,如果使用战争包装,它应该可以工作.与java -jar一起启动时,可执行的war将起作用,并且还将可部署到任何标准容器中.使用可执行jar时,不支持JSP. Undertow不支持JSP. 创建定制的error.jsp页面不会覆盖默认视图以进行错误处理.应该改用自定义错误页面.

With Jetty and Tomcat, it should work if you use war packaging. An executable war will work when launched with java -jar, and will also be deployable to any standard container. JSPs are not supported when using an executable jar. Undertow does not support JSPs. Creating a custom error.jsp page does not override the default view for error handling. Custom error pages should be used instead.

我已经克隆了可以运行项目的GitHub项目(如果按照以下步骤操作,您的问题肯定会得到解决)

I have clone your GitHub project able to run project(if you follow below steps your problem will get solve definitely)

Step To run your project :

Step 1 : Create war package of your project

Step 2 : Run your war package using below command 

    java -jar <your war file name> 

    i.e for your project command should be like :

      java -jar  auth-1.3.5.RELEASE.war

Step 3 : Hit the URL  http://localhost:5000/

您可以在浏览器中查看结果.

You can see the result in browser.

更多参考资料: 查看全文