-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use of Spring Boot Parent may break spring.profiles.active #25979
Comments
…spring-boot-parent definition Update the generator templates for Gradle and Maven to use the Spring default delimiter of the commercial-at sign (`@`). Remove the JHipster configuration of the delimiter and default to Spring Boot Parent's configuration and allow it to inherit. This will properly scope the config/bootstrap*.yml and allow Spring Boot's root resources definition to handle the **/application*.yml files. Fixes jhipster#25979
…spring-boot-parent definition Update the generator templates for Gradle and Maven to use the Spring default delimiter of the commercial-at sign (`@`). Remove the JHipster configuration of the delimiter and default to Spring Boot Parent's configuration and allow it to inherit. This will properly scope the config/bootstrap*.yml and allow Spring Boot's root resources definition to handle the **/application*.yml files. Fixes jhipster#25979
@timothystone I tested JHipster 8.3.0 and 21-Points using the following technique:
The screenshot below shows the If I re-create the project with Maven, there is an error on startup. If I use your fix in #25980, both Gradle and Maven seem to work as expected. Am I understanding things correctly that this only affects Maven projects? |
@mshima While testing this, I noticed the following warning:
|
... snip ...
Yes, mainly a Maven issue, but Gradle does a "brute force" filtering using The PR does two (2) things: removes JHipster's configuration of the resource plugin's |
Thanks for the explanation, @timothystone. I appreciate it! |
I'll admit I was focused on Maven (never really jumped on the Gradle train) and don't have a Gradle environment to play in so I didn't see this. Seems like a key oversight in the |
@mraible I should write some tests for this. 😞 All the tests passed in the release of 8.3.0 suggesting that a) either they all use As I noted in the PR, when a discovery provider is provided, the |
Overview of the issue
The introduction of the Spring Boot Parent POM in #25602—besides messing with side-by-side blueprints that inject a company parent—has introduced conflicting configuration expectations to the Maven Resources Plugin configuration in JHipster 8.3.0.
This appears to stem from root
resources
definitions introduced by the Spring Boot Parent POM (see below).This is further complicated when you use any service discovery, e.g., Consul. This adds a
boostrap.yml
andbootstrap-prod.yml
configuration supported by theorg.springframework.cloud:spring-cloud-starter-bootstrap
dependency added when choosing a Discovery type in the generation of the project.As the
bootstrap*.yml
files are not scoped by the rootresources
definition, but scoped by JHipster's configuration the filtering takes place and the behavior of discovery bootstrapping takes precedence in the application. 😌Motivation for or Use Case
Use of expected profiles in Maven, e.g,
-P prod
, fail to start the application, defaulting todev, api-docs
when not using discovery. When discovery is turned on, the behavior is masked and the application appears to behave correctly.Note: This will generate bundles and other code for the
prod
profile, but the application will not start because H2 is not found (thedev
profile database) withjava.lang.ClassNotFoundException: org.h2.server.web.JakartaWebServlet
.Reproduce the error
Generate a common monolith with JHipster 8.3.0 (sse demo project using @mraible's 21-points).
Generate the Maven Effective POM—this is the computed POM that Maven processes,
mvn -P prod help:effective-pom
. Depending on your IDE it may or may not be easy to resolve how the POM was computed. NetBeans provides this annotation and you can see how and where resolution of elements happen.Spring defines the
application*.yml
andapplication*.properties
files with a "deep glob," e.g.,**/applications*.yml
. This pulls in the JHipster's location ofconfig/application*.yml
and thus excludes them by defintion. Yet, Spring Boot defines the Resources Pluginconfiguration
to use the Spring@
("commercial-at").When the application has chosen to use Service Discovery, this configuration of resource filtering by the Spring Boot Parent is masked as the
bootstrap*.yml
are only scoped by JHipster's maven-resource-plugin execution configuration, e.g.,config/*.yml
.In all, these conflicting definitions result in JHipster's
config-resources
definition being effectively ignored or incorrectly computed in the effective POM.Related issues
See #25602 when the Spring Boot Parent POM was introduced.
Suggest a Fix
See PR #25980 for details, but in summation, edit JHipster's resources configuration deferring to Spring Boot Parent's configuration and use the native syntax, e.g.,
@spring...@
, in theapplication*
andbootstrap*
files generated by JHipster.Workaround:
Correct the
spring.profiles.active
values to@spring.profiles.active@
, i.e., specifically:JHipster Version(s)
Detalls below.
JHipster configuration
Welcome to JHipster v8.3.0
JHipster configuration, a
.yo-rc.json
file generated in the root folder.yo-rc.json file
Environment and Tools
openjdk version "17.0.9" 2023-10-17
OpenJDK Runtime Environment Temurin-17.0.9+9 (build 17.0.9+9)
OpenJDK 64-Bit Server VM Temurin-17.0.9+9 (build 17.0.9+9, mixed mode)
git version 2.39.3 (Apple Git-146)
node: v20.12.2
npm: 10.5.0
Docker version 26.0.0, build 2ae903e
JDL for the Entity configuration(s)
entityName.json
files generated in the.jhipster
directoryJDL entity definitions
Browsers and Operating System
Mac OS 15, intel MacBook Pro
Maven 3.9.6
Java 17
Checking this box is mandatory (this is just to show you read everything)
The text was updated successfully, but these errors were encountered: