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 bootRepackage -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.
In default mode, 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.
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, in order to have an executable WAR file, you should also run Maven or Gradle with the "prod" profile:
- With Maven, run
./mvnw -Pprod package
(ormvn -Pprod package
) - With Gradle, run
./gradlew -Pprod bootRepackage
(orgradle -Pprod bootRepackage
)
When you run your production application, don't forget to add the "prod" profile, by adding --spring.profiles.active=prod
to your program arguments:
./java -jar jhipster-0.0.1-SNAPSHOT.war --spring.profiles.active=prod
Spring profiles switches
JHipster comes with two additionnal Spring "profiles" used as switches:
no-swagger
to disable swaggerno-liquibase
to disable liquibase
These can be used along with both dev
and prod
profiles.
Please note that no-swagger
doesn't have any effect on prod
profile as swagger is disabled by default on that profile.
The are only used at run time:
- In your IDE, run your main applcation class with
spring.profiles.active=dev,no-swagger,no-liquibase
(please note you need to activate the "dev" or "prod" 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 "-Drun.profiles=no-liquibase"
./mvnw "-Drun.profiles=no-liquibase,no-swagger"
With Gradle, you can also use those profiles directly:
./gradlew -Pprod -Pno-liquibase
./gradlew -Pno-liquibase -Pno-swagger