hippo-on-spring-boot, a demo project to wrap a Hippo project into single JAR executable Spring Boot application.
This project uses hipshoot Spring Boot Support library to wrap a Hippo project into a Spring Boot application package.
In summary,
- This demo project was simply generated by following Getting Started with Hippo CMS.
- Simply added some built-in example features using Essentials such as News, Events, etc.
- Added spring-boot-deploy Maven submodule which lets us wrap Hippo project into single JAR executable Spring Boot application by following hipshoot Spring Boot Support library.
- Added test.sh and test.bat to show how to execute the single executable JAR.
- That's it.
$ mvn clean package
$ cd spring-boot-deploy
$ rm -rf ./repository/
$ ./test.sh
You can also pass environment-specific profile ('prod', 'acct', 'test', etc.):
$ cd spring-boot-deploy
$ rm -rf ./repository/
$ ./test.sh --spring.profiles.active=prod
For environment specific profiles, please see application.yml. Also, please look up Spring Boot Reference documentation about how to configure/use multiple profiles in application.yml file.
The last command (./test.sh --spring.profiles.active=prod
) can be replaced with this (by setting environment variable for environment profile instead):
$ export SPRING_PROFILES_ACTIVE=prod
$ ./test.sh
Or, you can update test.sh
to pass a system property instead (e.g, -Dspring.profiles.active=prod
) instead, too.
Note: you can skip removing ./repository/ directory if you want to keep the existing Hippo repository storage directory.
Or, on Windows,
> cd spring-boot-deploy
> test.bat
See test.sh or test.bat.
It's just a simple java
command line.
You can simply type Ctrl-C to stop it.
Visit http://localhost:8080/site/ and http://localhost:8080/cms/.
See application.yml.
See Deploying to the cloud in Spring Boot documentation for detail.
You can use very simple commands like the following example when deploying onto Cloud Foundry:
$ cd spring-boot-deploy
$ cf login -a https://api.run.pivotal.io
$ cf push hippo-on-spring-boot \
-f manifest.yml \
-p target/hippo-on-spring-boot-spring-boot-deploy-0.1.0-SNAPSHOT.jar \
-t 180
To stop the application: cf stop spring-boot-deploy
To delete the application: cf delete spring-boot-deploy
You can also monitor the application through PCF Console (e.g, https://console.run.pivotal.io/).
After deployment, for example, you can visit:
Note: Please also take a look at manifest.yml which defines various environment settings.
Especially, JBP_CONFIG_SPRING_AUTO_RECONFIGURATION: '[enabled: false]'
must be set in order to disable
PCF Auto-Reconfiguration feature.
Otherwise, the JNDI resources such as DataSources would cause problems in this kind of multi-wars based deployment scenarios.
Sometimes, you might want to start up the servlet container fast enough without waiting for the Hippo RepositoryServlet
to complete its long initialization steps (such as storage and lucene index recreation). If its initialization time is more than some threshold (e.g, 60 seconds by default in CloudFoundry), it could cause failing of the push.
So, in this demo project, the Repository servlet in cms/src/main/webapp/WEB-INF/web.xml was replaced by DeferredInitDelegatingServlet for deferred asynchronous initialization. This way, you can start up the servlet container fast enough without having to wait for the RepositoryServlet to initialize synchronously. This optional feature can be very helpful when deploying onto cloud based platform such as CloudFoundry.