Profiles
JHipster comes with two Spring profiles :
dev
for development: it focuses on ease of development and productivityprod
for production: it focuses on performance and scalability
Those profiles come in two different configurations:
- The Maven/Gradle profiles are used at build time. For example
./mvnw -Pprod package
or./gradlew bootWar -Pprod
will package a production application. - The Spring profiles work at run time. Some Spring beans will behave differently, depending on the profile.
Spring profiles are set by Maven/Gradle, so we have a consistency between the two methods: you will have a prod
profile on Maven/Gradle and Spring at the same time.
Note: Spring profiles are used to configure the JHipster application properties, so you should be interested in reading our Common application properties documentation.
By default, JHipster will use the dev
profile
If you run the application without Maven/Gradle, launch the “Application” class (you can probably run it easily from your IDE by right-clicking on it).
If you run the application with Maven, run ./mvnw
to use our Maven Wrapper, or mvn
to use your own Maven installation.
If you run the application with Gradle, run ./gradlew
to use our Gradle Wrapper, or gradle
to use your own Gradle installation.
When using Angular 2+ if you need to do a clean run with webpack compilation enabled for dev
profile you can pass the webpack
param as below
./mvnw -Pdev,webpack
or
./gradlew -Pdev -Pwebpack
In production, JHipster has to run with the prod
profile
You can run JHipster in production directly using Maven or Gradle:
- With Maven, run
./mvnw -Pprod
(ormvn -Pprod
) - With Gradle, run
./gradlew -Pprod
(orgradle -Pprod
)
If you want to package your application as an executable WAR file, you should provide Maven or Gradle with a profile. E.g.,:
- With Maven, run
./mvnw -Pprod package
(ormvn -Pprod package
) - With Gradle, run
./gradlew -Pprod bootWar
(orgradle -Pprod bootWar
)
When you run your production application from a WAR file, the default is to use the same profile(s) as used during packaging. If you want to override this, you can explicitly provide an alternative in VM argument:
./java -jar jhipster-0.0.1-SNAPSHOT.war --spring.profiles.active=...
Spring profiles switches
JHipster comes with two additional profiles used as switches:
swagger
to enable swaggerno-liquibase
to disable liquibase
These can be used along with both the dev
and prod
profiles. Please note that by default, the swagger
profile is disabled in prod
and enabled in dev
by setting the spring.profiles.include
property in application.yml
.
swagger
and no-liquibase
are only used at runtime:
- In your IDE, run your main application class with
spring.profiles.active=dev,no-liquibase
(please note you need to include thedev
orprod
profile explicitly) - With a packaged application:
./java -jar jhipster-0.0.1-SNAPSHOT.war --spring.profiles.active=prod,no-liquibase
With Maven, you can also use those profiles directly:
./mvnw -Pprod,swagger,no-liquibase
./mvnw -Pdev,no-liquibase
With Gradle, you can also use those profiles directly:
./gradlew -Pprod -Pswagger -Pno-liquibase
./gradlew -Pno-liquibase