The Java blog system of Docker+SpringBoot+Mybatis+thymeleaf is open source

personal blog

For technicians, having their own personal blog should be a desirable thing. They can record and share their opinions. It is interesting to think about it , but when I first started blogging, I didn’t have a personal blog in my mind. The idea of ​​blogging, because when I first started, I didn’t even know how many blogs I could stick to, but as time went on, the number of blogs increased, and the idea of ​​building a private blog website became stronger and stronger. Independent development, independent maintenance, and then adding other functions to the project a little bit as needed, although I have never experienced this feeling, it should be quite cool .
While working, I updated the code and blog of ssm-maven. In fact, the time occupied by these tasks is very intensive, enough to keep me busy and unable to find the north. Due to time reasons, I also delayed a lot of blogs. In this case, I am still preparing for my personal blog site, modifying the Tale project, doing a lot of coding work, and now I am starting to prepare for the launch of this project and the corresponding introduction blog post, Also a bit silly.
OK, having said so much, many people must think that I am bragging. Yes, I am complimenting myself, because it is really hard work. Sometimes I still have to give myself a little applause and self-encouragement, otherwise I will Not sure why I do so much, hahahahaha.

Reasons for choosing Tale as a template and personal thoughts

There are many open source commercial blog platforms, and there are naturally many excellent ones, but they are generally commercial platforms. For developers, they may pursue flexibility and maintainability. Therefore, develop a blog platform by yourself or do it on an excellent open source blog. Secondary development is better. Coincidentally, when I was thinking about how to start this work, I saw a blog post about the Java open source blog system Tale. At that time, the company also had a lot of work, so I collected it and studied it after a while. Then I started to transform and carry out secondary development according to my own ideas. I will talk about this later, or talk about the Tale blog system. When I opened this blog website, my eyes were instantly attracted. It is simple, beautiful, and generous. It is very comfortable to go up. A white shirt in the hot summer is refreshing and white. I really liked this blog at first sight. Then I went to study the deployment of the project (the process is not shown), and experienced the background functions. As a blog template, the functions are relatively complete, and it can basically meet the needs of private blog sites, so I plan to use this system as my own. personal blog website template.
The effect of the home page is shown in the figure below. Since the original Tale website cannot be opened, the rendering of Tale cannot be seen. This screenshot is the picture of the homepage of my website. The template is the same. I believe you will like this rendering. From this blog:
13Blog homepage renderings

As for why it took more than a month for secondary development, so that it was launched on May 13, there are the following reasons:

  • The original project was developed using the Blade framework
  • Domain name and cloud server purchase, website ICP filing
  • 整合docker、docker-compose
  • install process modification
  • Some functional modifications
  • Too busy at work to be fully engaged
  • Exactly the 13th, yes, 13

In the system settings in the background of the original Tale blog, there is an option to turn off "Allow Reinstallation". This default setting is "Off", but you can actually enter the installation page. If some netizens can guess the blogger's database username and password, It is estimated that the other party's blog can be given to a pot. This problem should be fixed now, but this problem existed when I first saw this project in March, so I thought of modifying it.
install process
install process

Another reason is the install module in the code. After downloading and running it, I always feel that this process is very awkward. First of all, this is a private blog system. The relevant configuration of the database should be determined. If there is no accident, it should not be If there are changes, it should be better to write it directly in the code. Personally, I feel that the meaning of the database initialization step in the install module is not very significant or even redundant (personal opinion). In addition, it is not particularly safe to directly expose this page and interface address. So want to rewrite the process.

In the past month or so, the following modifications have been made: firstly, the whole project was transformed from Blade framework development to SpringBoot+Mybatis development , then Docker was integrated to simplify deployment, and secondly, the original install process was completely deleted and replaced by A script command implemented by docker-compose completes the initialization of the database and the startup of the project, without redundant operations.

Integrating Docker to simplify the deployment process

The original deployment process was:

  • Build a Java runtime environment,
  • install mysql database,
  • Initialization data,
  • Run the jar package.

In fact, there are not too many steps, but I was just getting started with Docker at that time, so I especially wanted to integrate Docker in the project to test my knowledge, and at the same time, it also reduced the deployment steps, but deleted the install process. After that, I couldn’t help but think about whether the MySQL database installation and data initialization can also be implemented through Docker, so there is no need to manually build the database and run the database script (in fact, it is lazy). This implementation process takes a long time. Finally, the whole process is realized through docker-compose and some shell script commands. Just run one line of shell startup script command to realize Mysql database creation, data import, Mysql container creation and startup, blog container creation and startup, two containers connection interaction, project startup.
Code structure diagram

The startup script is as follows:

#!/usr/bin/env bash

set -e

mvn clean install -Dmaven.test.skip=true

# 停止原先运行的容器
docker-compose stop
docker-compose rm -f

#删除名称为none的镜像
docker images|grep none|awk '{print $3 }'|xargs docker rmi

# 使用docker-compose启动多容器应用
docker-compose up --build -d

# 日志
docker-compose logs -f

There are too many codes, so I will not put them up. If there is time in the future, I will introduce different functions and technologies in detail. Next is the viewing time:

Home page:
front page
Article details page:
Article page
Login page:
login page
Article list page:
Article list page
Article editing page :
Article edit page
Category Edit:
CategoryEdit

Epilogue

Personally, I am quite satisfied with this blog system, and I will continue to add functions in the future, such as search engine, caching function, ELK log system, etc., to further improve this system. Of course, the advanced chapter of the ssm project may be released in the near future. It's going to be delayed, and I'll write when I have time.

This is my personal blog address , everyone is welcome to browse, guide and criticize.

Since this is a personal site, the account number and password will not be announced, but the code of this blog system is open source and can be downloaded from my github repository. The address is here . If you have any questions, you can ask them here . Give me a star if you can.

If you can't access github, you can also go to the code cloud to download the project code.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325820668&siteId=291194637