@nxrocks/nx-spring-boot:serve
uses project .env
, ./gradlew bootRun
does not
#132
tschaffter
started this conversation in
General
Replies: 1 comment 1 reply
-
Hi Thomas, the response to your question is here: https://nx.dev/recipe/define-environment-variables Indeed, it is Nx that loads the This is not something gradle wrapper (nor maven wrapper) do by default (not their job), thus the need to combine them with another command |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm migrating Java projects from Maven to Gradle in the Nx monorepo Sage-Bionetworks/challenge-registry. I'm new to Gradle but the transition so far has been smooth minus one issue described in detailed in this post.
To summarize, an app has a file
.env
that includes variables used in the Spring Boot app fileapplication.yml
. When starting the app withnx serve <app-name>
, the app successfully starts, i.e. the values defined in.env
are successfully accessed by the app.When I move to the app folder and run
./gradlew bootRun
, which is the command run under the hood bynx serve <app-name>
, the app fails to start because the values defined in.env
are not used by the app. Starting the app withDB_URL=<value> ./gradlew bootRun
works.What could be the difference between running
nx serve <app-name>
from the workspace root folder and running./gradlew bootRun
from the app folder?Thanks for your help!
Beta Was this translation helpful? Give feedback.
All reactions