当前位置:网站首页>Handwriting a blogging platform ~ the first day
Handwriting a blogging platform ~ the first day
2022-08-02 01:56:00 【hiccup kid paper】
留给读者
关于博客,个人有手写过,说白就是独立开发一个应用,自己搭建服务器,部署、上线和维护项目这么一个过程,当然因为是第一天,所以这里对于不愿开发的,我就提供了一种便携的方式,先看效果图,本人的Hexo
静态博客网站,可以直接下载下來快速搭建,维护不需要服务器,只需要注册Github
,会点简单的命令和花几分钟时间去使用别人免费给的评论系统、阅读量统计就可以了.
给出链接:
先说说博客平台开发的需求分析:
开发工具:
- 首先需要一个
IDEA
开发工具,这是大家都公认且推荐最好的Java开发工具 - 其次是
JDK
,现在的JDK
不像1.8
之前版本的,是有两个包,目前版本JDK
包含了JRE
(Java Runtime Environment
),即Java
的运行环境,就是虚拟机环境,JDK
(Java Development Kit
),Kit
就是工具了,也就是一些api工具包,比如常用的java.util
、java.math
和java.io
等等.
环境:
Java
环境,也就是配置Java
的环境变量,目的是能够使用到Java
的bin
文件库,配置path
到JDK_HOME_PATH
目录路径Tomcat
环境,就是运行Java项目所需的容器,我们常开发的war
包就可以在tomcat的webapp
中启动,而jar
包(springboot
)就是内置了tomcat
的压缩包,它会自动放到springboot
内置的tomcat
中去启动,原理一样.Maven
环境,就是项目会依赖很多jar
包,我们需要一个软件方便去管理,当然你自己手动去管理也不是不行,使用maven
便携的原因有两点:第一,一键引入依赖包,不需手动考虑下载,第二,便于管理多模块化和聚合项目.
tomcat
容器启动关闭命令:
# linux 环境下
./bin/startup.sh # 启动
./bin/shutdown.sh # 关闭
# windows 环境下
.\bin\startup.bat # 启动
..\bin\shutdown.bat # 关闭
springboot
启动关闭命令:
java -jar [后缀.jar的项目路径] # 前台模式启动 fg
nohup java -jar [后缀.har的项目路径] & # 后台模式启动 bg
# 进阶
# 熟练点 linux bash 脚本命令还可以运行脚本一键启动并输出日志文件到自定义路径
java -jar [后缀.har的项目路径] > /dev/null & # 这种日志文件是启动日志文件,如运行日志文件需要到配置文件中配置
# 如对项目有配置信息的修改,我们使用默认约束,即规定的方式去配置
# 在 jar 包当前目录创建 ./config文件夹/application.properties文件,注意命令启动要与jar包同目录
# 例如:java -jar ./test.jar # 那么在./ 目录下就会去读取 ./config/application.properties
# 又比如当前在 /home/ 下
# 使用命令 [[email protected] home]java -jar /home/fyupeng/test.jar 读取的配置文件是在/home下的
# 所以有必要先 cd到当前目录下
# 或者指定外部命令指定配置文件位置,--spring.config.location=[路径]
# 这种方式我在springboot1.5 版本成功尝试过,在 2.0 以上就出问题了,使用默认约束就完事
# 注意:项目 jar 包 与 config/application.properties 放在一个文件夹中,启动的时候是去启动文件夹
提示:
[root@localhost jarList]# ls
test start.sh status.sh stop.sh
[root@localhost jarList]# ls ./test
[root@localhost jarList]# catalina.log config test.jar
[root@localhost jarList]# ls ./test/config
[root@localhost jarList]# application.properties
[root@localhost jarList]# ./start.sh test
# 下面给出完整代码:
start.sh
启动脚本:
#!/usr/bin/env bash
# 配置文件名称
# (该配置文件放置在jar包同级目录下并且必须存在已经配置文件名称具备统一性!!!请根据实际的配置文件名称进行修改)
CONFIG_FILE_NAME="application.properties"
# 启动一个目录下的所有jar包
function read_dir(){
for file in `ls $1`
do
#如果当前文件是文件夹则递归处理
if [ -d $1"/"$file ]
then
read_dir $1"/"$file
else
# 当前文件不是一个文件夹
if [[ -f $1"/"$file ]]
then
# 如果当前文件是一个.jar结尾的文件则启动它
if [[ ${file:0-4} == '.jar' ]];
then
echo $1/$file 开始启动...
cd ./$1
#nohup java -jar $1"/"$file --spring.config.location=$1"/"$CONFIG_FILE_NAME > /dev/null &
nohup java -jar ./$file > ./"catalina.log" &
echo 启动完成!
fi
fi
fi
done
}
#读取第一个参数
read_dir $1
status.sh
状态脚本:
#!/usr/bin/env bash
# 查看某个目录下所有jar程序的状态
function read_dir(){
for file in `ls $1`
do
#如果当前文件是文件夹则递归处理
if [ -d $1"/"$file ]
then
read_dir $1"/"$file
else
# 当前文件不是一个文件夹
if [[ -f $1"/"$file ]]
then
if [[ ${file:0-4} == '.jar' ]];
then
# 获取pid
pid=`ps -ef | grep $file | grep -v grep | awk '{print $2}'`
# -z 表示如果$pid为空时则输出提示
if [ -z $pid ];then
echo ""
echo "Service $file is not running!"
echo ""
else
echo ""
echo "Service $1"/"$file is running. It's pids=${pid}"
echo ""
fi
fi
fi
fi
done
}
#读取第一个参数
read_dir $1
stop.sh
关闭脚本
#!/usr/bin/env bash
# 停止一个目录下的所有jar程序
function read_dir(){
for file in `ls $1`
do
#如果当前文件是文件夹则递归处理
if [ -d $1"/"$file ]
then
read_dir $1"/"$file
else
# 当前文件不是一个文件夹
if [[ -f $1"/"$file ]]
then
if [[ ${file:0-4} == '.jar' ]];
then
# 获取pid
# 模糊匹配 $file 进程| 过滤自身命令进程 | 输出进程表中的进程号
pid=`ps -ef | grep $file | grep -v grep | awk '{print $2}'`
# -z 表示如果$pid为空时则输出提示
if [ -z $pid ]; then
echo ""
echo "Service $file is not running! It's not necessary to stop it!"
echo ""
else
# 杀死进程
kill -9 $pid
echo ""
echo "Service stop successfully!pid:${pid} which has been killed forcibly!"
echo ""
fi
fi
fi
fi
done
}
#读取第一个参数
read_dir $1
maven
项目命令:
# 清理项目 - 项目修改
mvn clean
# 安装到 仓库 - 运行项目用
mvn install
# 打包 - 部署项目用
mvn package
其他必要配置:
Tomcat
日志输出编码配置:
由于在大多数人在Win操作系统开发,默认系统编码为GBK
,而tomcat
日志输出默认为UTF-8
,开发工具Tomcat
也去配置输出console
根据系统来,这样就可以做到cmd
窗口和idea熊掌得兼的效果.
logging.properties
#java.util.logging.ConsoleHandler.encoding = UTF-8
java.util.logging.ConsoleHandler.encoding = GBK
Maven
镜像加速:
settings.xml
<mirrors>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
</mirrors>
JDK
官网下载地址:Download the Latest Java LTS Free
tomcat官网下载地址:https://tomcat.apache.org/download-80.cgi
maven官网下载地址:Maven - Download Apache Maven
下载推荐:免安装绿色版(易配置易卸载),JDK1.8
、Tomcat8
、Maven3.6
虽然JDK1.8
官网取消了免安装版的链接,没关系去OpenJdk
官网下载:OpenJDK JDK 18.0.2 GA Release
推荐开发者搜索引擎,开发者搜索-Beta-让技术搜索更简单高效,可以避免搜索垃圾信息
推荐开源软件搜索:OSCS | 开源软件供应链安全社区 | 让每一个开源项目变得更安全
更精彩的在第二天,嗝屁小孩纸正持续跟进中…
顺便给分享自己几年来做的技术专栏:https://github.com/fyupeng
边栏推荐
- Multi-Party Threshold Private Set Intersection with Sublinear Communication-2021:解读
- 喜报 | AR 开启纺织产业新模式,ALVA Systems 再获殊荣!
- 『网易实习』周记(二)
- 信息化和数字化的本质区别是什么?
- 第一次写对牛客的编程面试题:输入一个字符串,返回该字符串出现最多的字母
- Navicat数据显示不完全的解决方法
- Constructor of typescript35-class
- Record the pits where an error occurs when an array is converted to a collection, and try to use an array of packaging types for conversion
- 一本适合职场新人的好书
- LeetCode brushing diary: 53, the largest sub-array and
猜你喜欢
【ORB_SLAM2】void Frame::ComputeImageBounds(const cv::Mat &imLeft)
Two ways to pass feign exceptions: fallbackfactory and global processing Get server-side custom exceptions
Entry name ‘org/apache/commons/codec/language/bm/gen_approx_greeklatin.txt’ collided
Understand the big model in seconds | 3 steps to get AI to write a summary
3.Bean的作用域与生命周期
canal realizes mysql data synchronization
Reflex WMS中阶系列7:已经完成拣货尚未Load的HD如果要取消拣货,该如何处理?
【服务器数据恢复】服务器Raid5阵列mdisk磁盘离线的数据恢复案例
S/4中究竟有多少个模块,你对这些模块了解多少
【Brush the title】Family robbery
随机推荐
Detailed explanation of fastjson
字节给我狠狠上了一课:危机来的时候你连准备时间都没有...
Ask God to answer, how should this kind of sql be written?
Multi-Party Threshold Private Set Intersection with Sublinear Communication-2021: Interpretation
bool Frame::PosInGrid(const cv::KeyPoint &kp, int &posX, int &posY)
Moonbeam与Project Galaxy集成,为社区带来全新的用户体验
MySQL optimization strategy
Anti-oversold and high concurrent deduction scheme for e-commerce inventory system
秒懂大模型 | 3步搞定AI写摘要
The characteristics and principle of typescript29 - enumeration type
Yunhe Enmo: Let the value of the commercial database era continue to prosper in the openGauss ecosystem
大话西游创建角色失败解决
Day116.尚医通:预约挂号详情 ※
Data transfer at the data link layer
canal realizes mysql data synchronization
LeetCode刷题日记:153、寻找旋转排序数组中的最小值
密码学的基础:X.690和对应的BER CER DER编码
Record the pits where an error occurs when an array is converted to a collection, and try to use an array of packaging types for conversion
Redis 订阅与 Redis Stream
6-24 exploit-vnc password cracking