A blog site written in Spring Boot. Used by https://bianjp.com.
- Java 8
- PostgreSQL >= 9.0
- Redis
Extra development/building requirement:
- Node.js >= 6
- Yarn
- broccoli-cli
Spring Profiles are used to separate configurations for different environments.
This project has two profiles:
- development: Used for development environment
- production: Used for production environment
Only save common and non-sensitive configurations in src/main/resource/application-{profile}.yml files.
Local specific or sensitive configuration (eg: database password) can be passed in the following ways:
src/main/resource/config/application-{profile}.yml: Git ignored, will be included in packaged jarapplication-{profile}.ymlorconfig/application-{profile}.ymlin working directory (it's project root in development environment): Git ignored, will not be included in packaged jar- os environment variable
- Java system properties specified in command line
- command line arguments
For example, to specify redis host and datasource url by command line arguments:
java -jar build/libs/blog-spring-0.1.0-SNAPSHOT.jar --spring.profiles.active=production --spring.redis.host=127.0.0.1 --spring.datasource.url=jdbc:postgresql://localhost/blogSee Externalized Configuration for more details about configuration methods and precedence.
You should at least config datasource and redis.
Create an empty database, and Flyway will take care of the schema migrations.
Install npm dependencies if you haven't:
yarn installThen just start Spring Boot in your IDE or using gradle (./gradlew bootRun).
By default BroccoliServer will start a broccoli serve process listening on localhost:4200. Change assets.* properties as needed.
./gradlew build -x test
java -jar build/libs/blog-0.1.0-SNAPSHOT.jar --spring.profiles.active=productionIf you just need a single instance, using systemd is a good idea.
Create /etc/systemd/system/blog.service:
[Unit]
Description=Blog site
After=syslog.target
[Service]
User=YOUR_NORMAL_USER
WorkingDirectory=/path/to/working-directory
ExecStart=/usr/bin/java -jar /path/to/blog-0.1.0-SNAPSHOT.jar --spring.profiles.active=production --server.port=8080
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
sudo systemctl start blog
sudo systemctl enable blogThis project is licensed under the terms of the MIT license.