引言
在这篇文章中您将学习到:
- 使用 Spring boot 官方模板创建一个 springboot应用
- 安装使用 redis
- 链接数据库
- 打包 Spring boot 应用
- 发布一个 Spring boot 应用
开始
到 这里 拉取群管家后端代码。
使用 idea 或其他Java开发工具打开:
拉取依赖
稍等片刻,项目自己会自动拉取依赖
运行项目
先安装 redis,然后点击项目中的三角,运行即可
查看数据库
数据库表如下:
打包
发布
借助工具 finalShell 即可上传
相关的命令如下:
[root@VM-4-7-centos ~]# pwd
/root
[root@VM-4-7-centos ~]# ps -ef|grpe tomcat
-bash: grpe: 未找到命令
[root@VM-4-7-centos ~]# ps -ef|grep tomcat
root 2676 750 0 23:05 pts/1 00:00:00 grep --color=auto tomcat
root 16976 1 3 5月13 ? 4-00:50:47 /usr/local/java/jre1.8.0_231/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/prod-tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /usr/local/tomcat/prod-tomcat/bin/bootstrap.jar:/usr/local/tomcat/prod-tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat/prod-tomcat -Dcatalina.home=/usr/local/tomcat/prod-tomcat -Djava.io.tmpdir=/usr/local/tomcat/prod-tomcat/temp org.apache.catalina.startup.Bootstrap start
root 20791 1 1 5月13 ? 1-11:40:10 /usr/local/java/jre1.8.0_231/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/test-tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /usr/local/tomcat/test-tomcat/bin/bootstrap.jar:/usr/local/tomcat/test-tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat/test-tomcat -Dcatalina.home=/usr/local/tomcat/test-tomcat -Djava.io.tmpdir=/usr/local/tomcat/test-tomcat/temp org.apache.catalina.startup.Bootstrap start
[root@VM-4-7-centos ~]#
[root@VM-4-7-centos ~]#
[root@VM-4-7-centos ~]#
[root@VM-4-7-centos ~]# cd /usr/local/tomcat/
[root@VM-4-7-centos tomcat]# ls
apache-tomcat-9.0.68.tar.gz prod-tomcat test-tomcat
[root@VM-4-7-centos tomcat]# cd test-tomcat/
[root@VM-4-7-centos test-tomcat]# ll
总用量 148
drwxr-x--- 2 root root 4096 4月 10 20:22 bin
-rw-r----- 1 root root 19992 10月 4 2022 BUILDING.txt
drwx------ 3 root root 4096 4月 11 19:46 conf
-rw-r----- 1 root root 6210 10月 4 2022 CONTRIBUTING.md
drwxr-x--- 2 root root 4096 4月 10 20:22 lib
-rw-r----- 1 root root 57092 10月 4 2022 LICENSE
drwxr-x--- 2 root root 4096 9月 6 00:05 logs
-rw-r----- 1 root root 2333 10月 4 2022 NOTICE
-rw-r----- 1 root root 3398 10月 4 2022 README.md
-rw-r----- 1 root root 6901 10月 4 2022 RELEASE-NOTES
-rw-r----- 1 root root 16505 10月 4 2022 RUNNING.txt
drwxr-x--- 3 root root 4096 4月 12 22:23 temp
drwxr-x--- 9 root root 4096 5月 13 21:51 webapps
drwxr-x--- 3 root root 4096 4月 10 20:22 work
[root@VM-4-7-centos test-tomcat]# cd webapps/ls
-bash: cd: webapps/ls: 没有那个文件或目录
[root@VM-4-7-centos test-tomcat]# cd webapps/
[root@VM-4-7-centos webapps]# ls
algorithm-web-admin detection-wab-admin qunguanjia-web-admin reservation-web-user
algorithm-web-admin.war detection-wab-admin.war qunguanjia-web-admin.war reservation-web-user.war
algorithm-web-user detection-wab-worker qunguanjia-web-user
algorithm-web-user.war detection-wab-worker.war qunguanjia-web-user.war
[root@VM-4-7-centos webapps]# ll
总用量 601252
drwxr-x--- 5 root root 4096 5月 1 07:07 algorithm-web-admin
-rw-r--r-- 1 root root 83684899 5月 1 07:06 algorithm-web-admin.war
drwxr-x--- 5 root root 4096 5月 11 17:06 algorithm-web-user
-rw-r--r-- 1 root root 106212996 5月 11 17:05 algorithm-web-user.war
drwxr-x--- 5 root root 4096 5月 13 21:51 detection-wab-admin
-rw-r--r-- 1 root root 70982836 5月 13 21:48 detection-wab-admin.war
drwxr-x--- 5 root root 4096 5月 13 20:28 detection-wab-worker
-rw-r--r-- 1 root root 70073536 5月 13 20:27 detection-wab-worker.war
drwxr-x--- 5 root root 4096 5月 4 21:22 qunguanjia-web-admin
-rw-r--r-- 1 root root 83685229 5月 4 21:21 qunguanjia-web-admin.war
drwxr-x--- 5 root root 4096 5月 11 13:01 qunguanjia-web-user
-rw-r--r-- 1 root root 106213064 5月 11 12:59 qunguanjia-web-user.war
drwxr-x--- 5 root root 4096 5月 6 19:39 reservation-web-user
-rw-r--r-- 1 root root 94770215 5月 6 19:38 reservation-web-user.war
[root@VM-4-7-centos webapps]# pwd
/usr/local/tomcat/test-tomcat/webapps
[root@VM-4-7-centos webapps]#
[root@VM-4-7-centos webapps]#
[root@VM-4-7-centos webapps]# kill -9 20791
[root@VM-4-7-centos webapps]#
[root@VM-4-7-centos webapps]#
[root@VM-4-7-centos webapps]#
[root@VM-4-7-centos webapps]# ps -ef|grep tomcat
root 7989 750 0 23:07 pts/1 00:00:00 grep --color=auto tomcat
root 16976 1 3 5月13 ? 4-00:50:51 /usr/local/java/jre1.8.0_231/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/prod-tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /usr/local/tomcat/prod-tomcat/bin/bootstrap.jar:/usr/local/tomcat/prod-tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat/prod-tomcat -Dcatalina.home=/usr/local/tomcat/prod-tomcat -Djava.io.tmpdir=/usr/local/tomcat/prod-tomcat/temp org.apache.catalina.startup.Bootstrap start
[root@VM-4-7-centos webapps]#
[root@VM-4-7-centos webapps]#
[root@VM-4-7-centos webapps]#
[root@VM-4-7-centos webapps]#
[root@VM-4-7-centos webapps]#
[root@VM-4-7-centos webapps]#
[root@VM-4-7-centos webapps]# sh ../bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat/test-tomcat
Using CATALINA_HOME: /usr/local/tomcat/test-tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/test-tomcat/temp
Using JRE_HOME: /usr/local/java/jre1.8.0_231
Using CLASSPATH: /usr/local/tomcat/test-tomcat/bin/bootstrap.jar:/usr/local/tomcat/test-tomcat/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Tomcat started.
[root@VM-4-7-centos webapps]# ps -ef|grep tomcat
root 8878 1 45 23:08 pts/1 00:00:02 /usr/local/java/jre1.8.0_231/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/test-tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /usr/local/tomcat/test-tomcat/bin/bootstrap.jar:/usr/local/tomcat/test-tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat/test-tomcat -Dcatalina.home=/usr/local/tomcat/test-tomcat -Djava.io.tmpdir=/usr/local/tomcat/test-tomcat/temp org.apache.catalina.startup.Bootstrap start
root 9082 750 0 23:08 pts/1 00:00:00 grep --color=auto tomcat
root 16976 1 3 5月13 ? 4-00:50:52 /usr/local/java/jre1.8.0_231/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/prod-tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -Dignore.endorsed.dirs= -classpath /usr/local/tomcat/prod-tomcat/bin/bootstrap.jar:/usr/local/tomcat/prod-tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat/prod-tomcat -Dcatalina.home=/usr/local/tomcat/prod-tomcat -Djava.io.tmpdir=/usr/local/tomcat/prod-tomcat/temp org.apache.catalina.startup.Bootstrap start