aws elastic beanstalk springboot fat war:找不到jsp

cidc1ykv  于 2021-06-29  发布在  Java
关注(0)|答案(2)|浏览(346)

我有

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

在我的application.properties中。我创建了一个独立的战争 gradle bootWar . jsp文件在本地运行时可以很好地解析,但是在eb上找不到jsp文件,它以404结束。我使用的是一个简单的eb amz linux 2环境。
值得注意的是eb如何运行文件: java -jar application.**jar** 而不是 java -jar application.**war** .
我的问题是:
把它当作一场战争来运作能解决问题吗?我该如何让eb把它当作一场战争来运作?
如果ans.to#1要在eb tomcat环境中使用非独立的war,那么我有什么选项可以让它使用ssl?独立war使用应用程序属性配置ssl。这还能继续吗?
谢谢你的帮助。

htrmnn0y

htrmnn0y1#

我修复了war打包和在eb-tomcat环境中部署它的问题。ssl现在由nginx反向代理而不是应用服务器来处理。
以下是我的nginx代理配置,以备不时之需:

user                    nginx;
error_log               /var/log/nginx/error.log warn;
pid                     /var/run/nginx.pid;
worker_processes        auto;
worker_rlimit_nofile    32714;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    include       conf.d/*.conf;

    map $http_upgrade $connection_upgrade {
        default     "upgrade";
    }

    server {
        listen       443 default ssl;
        server_name  localhost;
        error_page  497 https://$host$request_uri;

        ssl_certificate      <full-path-to-fullchain.pem>;
        ssl_certificate_key  <full-path-to-privkey.pem>;

        ssl_session_timeout  5m;
        ssl_protocols  TLSv1.1 TLSv1.2;
        ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
        ssl_prefer_server_ciphers   on;

        if ($ssl_protocol = "") {
          rewrite ^ https://$host$request_uri? permanent;
        }

        client_header_timeout 60;
    client_max_body_size  10M;
        client_body_timeout   60;
        keepalive_timeout     60;
        gzip                  off;
        gzip_comp_level       4;
        gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;

        # Include the Elastic Beanstalk generated locations
        include conf.d/elasticbeanstalk/*.conf;

    }

    server {
        listen 80;
        return 301 https://$host$request_uri;
    }
}
mnowg1ta

mnowg1ta2#

我使用一个带thymeleaf的spring启动应用程序,从来没有遇到过在templates文件夹中找不到视图的问题。请参阅本aws教程,该教程构建了一个基本的spring引导应用程序,该应用程序调用aws服务并将其部署到aws elastic beanstalk。
顺便说一下,这个应用程序是作为jar部署的:
https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javav2/usecases/creating_first_project

相关问题