I have a springboot application deployed into Google Cloud via AppEngine. I need to serve static resources out of appengine instances and I used this documentation: https://cloud.google.com/appengine/docs/standard/java11/serving-static-files .
The problem always (a lot of tests done) is (google cloud console error): "Static file referenced by handler not found"
I tested several configurations... but had no luck.
My app.yaml (last one):
runtime: "@appengine.runtime@"
env: "standard"
entrypoint: "java -noverify -jar myjar.jar -cp BOOT-INF/classes/:BOOT-INF/lib/* com.....config.Application"
instance_class: "@appengine.instance.class@"
inbound_services:
- warmup
vpc_access_connector:
name: "projects/@cloud.application@/locations/@cloud.region@/connectors/@cloud.redis.connector@"
handlers:
- url: /resources/(.*)$
static_files: /static/\1
upload: /static/.*\.(png)$
require_matching_file: false
automatic_scaling:
...
Static resources are placed inside.jar: BOOT-INF/classes/static
I tried in app.yaml:
- static_files: BOOT-INF/classes/static/\1
- static_files: classes/static/\1
No luck.
Any idea?
This is working for me: (app.yaml)
...
entrypoint: java -noverify -cp "BOOT-INF/resources/:BOOT-INF/classes/:BOOT-INF/lib/*" com.myorg.MySpringBootApp
handlers:
- url: /(.*\.(gif|png|jpg|svg|ico|css|js|html))$
static_files: BOOT-INF/classes/static/\1
upload: BOOT-INF/classes/static/.*\.(gif|png|jpg|svg|ico|css|js|html)$
secure: always
- url: /.*
secure: always
redirect_http_response_code: 301
script: auto
...
BOOT-INF
META-INF
app.yaml
org
Now you'll see that eg your js-Files have appropriate headers:
...
cache-control: public, max-age=600
content-encoding: gzip
etag: "uh4VxA"
...
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.