Closed logicglobe closed 9 months ago
That's not a bug, but a design decision. The image is part of the compilation, it's optimized and moved to the outputPath.
You have a few options:
allow anonymous access to jpg files at https://github.com/jhipster/generator-jhipster/blob/b9634b9be97d7602268bf45285856e320ccd0d91/generators/server/templates/src/main/java/_package_/config/SecurityConfiguration_imperative.java.ejs#L193
use an absolute path to access `/content/images/library.jpg
We only provide anonymous access to assets we provide and we don't provide any jpg files by default.
Added mvc.pattern("/*.jpg")
to SecurityConfiguration.java
and... HEY PRESTO! Problem solved!!
Thanks for everything @mshima
FWIW, Spring Security changed its behavior between Spring Boot 2 and 3. Spring Boot 2 (aka JHipster 7) was allow by default. Spring Boot 3 is deny by default.
Important info. Thanks @mraible
Overview of the issue
JPG images don't show in production.
Motivation for or Use Case
I'd like to use JPG images.
Reproduce the error
Steps to reproduce
/src/main/webapp/content/images
home.component.scss
to use new image1. Create simple monolithic project
I created a simple monolithic project,
myapp
, with Gradle for the build tool, Angular front end, MariaDB for development and production: See the following.yo-rc.json
file:After project creation, added necessary database username/password to
application.yml
,liquibase.gradle
, etc.2. Add a JPG to images directory
Added a simple JPG image to the
/src/main/webapp/content/images
directory. The image I used is attached.3. Modify
home.component.scss
to use new imageModified
/src/main/webapp/app/home/home.component.scss
to use the JPG image as follows:4. Deploy into production
Deployed the application into production:
./gradlew -Pprod clean bootJar
myapp.jar
java -jar myapp.jar
http://localhost:8080
5. Image doesn't appear
The image does not appear. Browser console error shows:
6. Observations
Some observations:
http://localhost:8080/content/images/library.jpg
Related issues
None.
Suggest a Fix
No idea...
JHipster Version(s)
8.1.0
JHipster configuration
See steps above.
Entity configuration(s)
entityName.json
files generated in the.jhipster
directoryNo entities generated (except the core ones).
Browsers and Operating System