微信云托管部署springboot项目

 

步骤

1.打包springboot项目为docker镜像上传到虚拟机/服务器

2.上传镜像到腾讯云镜像服务中

3.微信云托管部署项目

1.打包springboot项目为docker镜像上传到虚拟机/服务器

1.springboot项目引入docker依赖

 

<build>
    <plugins>
        <plugin>
            <groupId>com.spotify</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>1.2.2</version>
            <configuration>
                <!-- 镜像名 -->
                <imageName>${project.artifactId}</imageName>
                <!-- 镜像版本 -->
                <imageTags>
                    <imageTag>${project.version}</imageTag>
                </imageTags>
                <!-- Docker路径 -->
                <dockerHost>http://ip4:2375</dockerHost>
                <!-- Dockerfile定义 -->
                <baseImage>openjdk:11</baseImage>
                <!-- 作者 -->
                <maintainer>jkw</maintainer>
                <resources>
                    <resource>
                        <!-- 复制jar包到docker容器指定目录 -->
                        <targetPath>/</targetPath>
                        <!-- 从哪个包拷贝文件,target包 -->
                        <directory>${project.build.directory}</directory>
                        <!-- 拷贝哪个文件 -->
                        <include>${project.build.finalName}.jar</include>
                    </resource>
                </resources>
                <workdir>/</workdir>
                <entryPoint>["java", "-jar", "${project.build.finalName}.jar"]</entryPoint>
                <forceTags>true</forceTags>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <excludes>
                    <exclude>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                    </exclude>
                </excludes>
            </configuration>
        </plugin>
    </plugins>
</build>

2.打包项目

3.上传项目

 

2.上传镜像到腾讯云镜像服务 

腾讯云镜像服务:https://console.cloud.tencent.com/tcr/repository

1.确保你已经在本地安装了Docker运行时环境并构建好了要上传的镜像,确认你有腾讯云账号,并已开通容器镜像服务。

2.登录到腾讯云容器镜像服务:

docker login ccr.ccs.tencentyun.com --username=xxx

 输入密码,如果密码忘了可以在以下地方重置

3.给镜像打标签:

docker tag 镜像id【镜像名称:版本号】 ccr.ccs.tencentyun.com/你的命名空间/镜像:版本

4.上传镜像:

docker push ccr.ccs.tencentyun.com/你的命名空间/myapp:v1.0

 5.在控制台中查看你的命名空间下是否出现了刚刚上传的镜像,包括镜像名称、版本号、大小等信息

 3.登录微信云托管

 

4.云端调试测试 

5.微信小程序使用 

const cloud = wx.cloud.init();
wx.cloud.callContainer({
      "config": {
        "env": "your-default-environment-id"
      },
      "path": "/front/courseType/search?page=1&size=10",
      "header": {
        "X-WX-SERVICE": "wtl",
        "content-type": "application/json"
      },
      "method": "GET",
      "data": ""
    }).then(res => {
      if (res.data.code == 200) {
        // 成功回调
        console.log(res.data.data.records);
      }
    }).catch(err => {
      // 失败回调
      console.error(err);
    });

 

 

  • 5
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

月木@

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值