本文转载自微信公众号「JAVA日知录」,作者飘渺Jam。转载本文请联系JAVA日知录公众号。
现有 一个微服务项目,按照业务拆分为如下几个模块
在项目根路径下执行,Maven 命令,截取 2 段输出
- mvn clean install -pl com.lab:book-common -am -Ptest
- [INFO] Reactor Build Order:
- [INFO]
- [INFO] school_parent [pom]
- [INFO] common [pom]
- [INFO] cloud-common [jar]
- [INFO] book-common
- [INFO] Reactor Summary for school_parent 0.0.1-SNAPSHOT:
- [INFO]
- [INFO] school_parent ...................................... SUCCESS [ 0.761 s]
- [INFO] common ............................................. SUCCESS [ 0.083 s]
- [INFO] cloud-common ....................................... SUCCESS [ 6.430 s]
- [INFO] book-common ........................................ SUCCESS [ 3.236 s]
- [INFO] ------------------------------------------------------------------------
- [INFO] BUILD SUCCESS
- [INFO] ------------------------------------------------------------------------
- [INFO] Total time: 11.880 s
- [INFO] Finished at: 2020-05-03T14:13:12+08:00
- [INFO] ------------------------------------------------------------------------
docker 和 docker-compose 适合 测试环境使用,生产环境用 Kubernetes,安装 步骤命令本站基本都有:http://javadaily.cn/
- root@jazz-pc:/opt# docker ps --format "table {{.Names}} ------------- {{.Image}}"
- NAMES ------------- IMAGE
- rmqbroker ------------- apacherocketmq/rocketmq:4.5.2-alpine
- rmqnamesrv ------------- apacherocketmq/rocketmq:4.5.2-alpine
- seata-server ------------- seataio/seata-server:1.2.0
- nacos ------------- nacos/nacos-server:1.2.1
- minio ------------- minio/minio
- es ------------- elasticsearch:7.6.2
- zookeeper ------------- zookeeper
- mysql ------------- mysql:5.7
- mongo ------------- mongo
- redis ------------- redis
- nohup java -Dserver.port=8858 -Dsentinel.dashboard.auth.username=sentinel -Dsentinel.dashboard.auth.password=Aa123456 -jar sentinel-dashboard-1.7.2.jar >sentinel.log 2>&1 &
- root@jazz-pc:/opt# mvn -v
- Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
- Maven home: /usr/local/apache-maven-3.6.3
- Java version: 11.0.7, vendor: Oracle Corporation, runtime: /usr/local/java/jdk-11.0.7
- Default locale: zh_CN, platform encoding: UTF-8
- OS name: "linux", version: "5.3.0-51-generic", arch: "amd64", family: "unix"
settings.xml 文件,加个国内镜像
aliyunmaven * 阿里云公共仓库 https://maven.aliyun.com/repository/public
顶级父工程 pom.xml 添加,跳过 单元测试 编译和执行
true true
如果有 Maven Nexus,则另外添加设置,install 替换为 deploy
- nohup java -jar /usr/local/jenkins/jenkins.war --ajp13Port=-1 --httpPort=8086 >/usr/local/jenkins/jenkins.out 2>&1 &
Jenkins JDK 环境 >=1.8 and <=11 目前最新版本不支持 Java 14
Jenkins 安装一般会卡住 2 次,则是去国外下载插件数据缓慢的原因,kill -9 进程 ID,ps -ef | grep jenkins 找到进程 ID。
第一次卡住修改 :/root/.jenkins/hudson.model.UpdateCenter.xml 文件里面链接内容为 国内镜像地址 https://mirrors.tuna.tsinghua.edu.cn/jenkins/updates/update-center.json
第二次卡住执行替换命令:
- cd /root/.jenkins/updates
- sed -i 's/http:\/\/updates.jenkins-ci.org\/download/https:\/\/mirrors.tuna.tsinghua.edu.cn\/jenkins/g' default.json && sed -i 's/http:\/\/www.google.com/https:\/\/www.baidu.com/g' default.json
- root@jazz-pc:/opt# which git
- /usr/bin/git
- root@jazz-pc:/opt# which svn
- /usr/bin/svn
- #!/bin/bash
- cd ./school
- mvn clean install -pl com.lab:book-common -am -Ptest
- echo 'install ok!'
- #!/bin/bash
- cd ./school/book-web
- mvn clean package -Ptest
- echo 'package ok!'
- echo 'build start!'
- service_name="book-web"
- service_prot=80
- IID=$(docker images | grep "$service_name" | awk '{print $3}')
- echo "IID $IID"
- if [ -n "$IID" ]
- then
- echo "exist $service_name image,IID=$IID"
- docker rmi -f $service_name
- echo "delete $service_name image"
- docker build -t $service_name .
- echo "build $service_name image"
- else
- echo "no exist $service_name image,build docker"
- docker build -t $service_name .
- echo "build $service_name image"
- fi
- CID=$(docker ps -a | grep "$service_name" | awk '{print $1}')
- echo "CID $CID"
- if [ -n "$CID" ]
- then
- echo "exist $service_name container,CID=$CID"
- docker stop $service_name
- docker rm $service_name
- else
- echo "no exist $service_name container"
- fi
- docker run -d --name $service_name \
- -v /etc/localtime:/etc/localtime:ro \
- -v /etc/timezone:/etc/timezone:ro \
- -v /data/logs:/data/logs:rw \
- --net=host -p $service_prot:$service_prot $service_name
- #!/bin/bash
- cd ./school/book-server
- mvn clean package -Ptest
- echo 'package ok!'
- echo 'build start!'
- service_name="book-server"
- service_prot=20880
- IID=$(docker images | grep "$service_name" | awk '{print $3}')
- echo "IID $IID"
- if [ -n "$IID" ]
- then
- echo "exist $service_name image,IID=$IID"
- docker rmi -f $service_name
- echo "delete $service_name image"
- docker build --no-cache -t $service_name .
- echo "build $service_name image"
- else
- echo "no exist $service_name image,build docker"
- docker build -t $service_name .
- echo "build $service_name image"
- fi
- CID=$(docker ps -a | grep "$service_name" | awk '{print $1}')
- echo "CID $CID"
- if [ -n "$CID" ]
- then
- echo "exist $service_name container,CID=$CID"
- docker stop $service_name
- docker rm $service_name
- else
- echo "no exist $service_name container"
- fi
- docker run -d --name $service_name \
- -e DUBBO_IP_TO_REGISTRY=192.168.1.6 \
- -e DUBBO_PORT_TO_REGISTRY=$service_prot \
- -e DUBBO_IP_TO_BIND=192.168.1.6 \
- -p $service_prot:$service_prot \
- -v /etc/localtime:/etc/localtime:ro \
- -v /etc/timezone:/etc/timezone:ro \
- -v /data/logs:/data/logs:rw \
- --net=host \
- $service_name
- FROM adoptopenjdk/openjdk11:jdk-11.0.7_10-alpine
- VOLUME ["/tmp","/data/logs"]
- COPY ./target/book-server-0.0.1-SNAPSHOT.jar book-server.jar
- ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/book-server.jar","&"]
book-web 执行构建 Build Now
book-web 前端 浏览器访问
login.html 登录模板示例页面,调用 /api/login 接口,内容如下
理想生活上天猫,登录页面 登录 短信登录 - new Vue({
- el: '#app',
- data: {
- userForm:{}, activeName: 'first'
- },
- methods: {
- login() {
- request({
- url: '/api/login',method: 'post',data: this.userForm,
- headers: {
- 'content-type': 'application/json;charset=UTF-8',"token": ''
- }
- }).then(response=>{
- var res = response.data;
- this.$message(res.message);
- })
- },
- handleClick(tab, event) {
- //console.log(tab, event);
- }
- }
- });
网站题目:基于微服务的CICD实战
URL地址:http://www.csdahua.cn/qtweb/news18/355368.html
网站建设、网络推广公司-快上网,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 快上网