Code Monkey home page Code Monkey logo

blog-spring's Introduction

Blog

A blog site written in Spring Boot. Used by https://bianjp.com.

Requirement

  • Java 8
  • PostgreSQL >= 9.0
  • Redis

Extra development/building requirement:

Configuration

Profiles

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 jar
  • application-{profile}.yml or config/application-{profile}.yml in 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/blog

See Externalized Configuration for more details about configuration methods and precedence.

Minimal configuration

You should at least config datasource and redis.

Create an empty database, and Flyway will take care of the schema migrations.

Running

Development

Install npm dependencies if you haven't:

yarn install

Then 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.

Production

./gradlew build
java -jar build/libs/blog-spring-0.1.0-SNAPSHOT.jar --spring.profiles.active=production

Systemd

If 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 blog

License

This project is licensed under the terms of the MIT license.

blog-spring's People

Contributors

bianjp avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.