mall商城微服务遇见的坑


【报错】

  • 使用nacos导入配置文件报错:未读取到合法数据,请检查导入的数据文件。

【原因】

  • 对比在naocs server中导出的文件,发现是少了一级目录。需要创建一个文件夹,名称为组的名称。
  • 因为在nacos上传文件时是可以选择命名空间的,但是不会选择组,所以nacos server识别报错了。

【解决】

  • 创建文件夹,命名为DEFAULT_GROUP,然后将配置文件放进去,打包上传成功。
  • 将修改的配置文件压缩成zip文件——上传配置文件。

【报错】
ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.2.2:build (build-image) on project

【解决】

  • 创建habor仓库,配置http模式。
  • docker加入harbor仓库认证.。
  • 服务器登录harbor仓库成功。
  • 修改pom.xml中仓库地址为:http://192.168.4.119:2375。
  • 执行行mvn clean package docker:build。
  • 确认生成镜像并且已经上传到仓库。

【报错】
Failed to execute goal on project mall-common: Could not resolve dependencies for project com.macro.mall:mall-common:jar:1.0-SNAPSHOT: Failed to collect dependencies for [com.github.pagehelper:pagehelper:jar:5.2.0 (compile), org.springframework.boot:spring-boot-starter-web:jar:2.3.0.RELEASE (compile), org.springframework.boot:spring-boot-starter-data-redis:jar:2.3.0.RELEASE (compile), org.springframework.data:spring-data-commons:jar:2.3.0.RELEASE (compile), com.github.xiaoymin:knife4j-micro-spring-boot-starter:jar:2.0.4 (compile), net.logstash.logback:logstash-logback-encoder:jar:5.3 (compile), org.springframework.boot:spring-boot-starter-validation:jar:2.3.0.RELEASE (compile), org.springframework.boot:spring-boot-starter-actuator:jar:2.3.0.RELEASE (compile), org.springframework.boot:spring-boot-starter-aop:jar:2.3.0.RELEASE (compile), org.springframework.boot:spring-boot-starter-test:jar:2.3.0.RELEASE (test), cn.hutool:hutool-all:jar:5.4.0 (compile), org.projectlombok:lombok:jar:1.18.12 (compile), org.springframework.boot:spring-boot-configuration-processor:jar:2.3.0.RELEASE (compile?)]: Failed to read artifact descriptor for org.apiguardian:apiguardian-api:jar:1.1.0: Could not transfer artifact org.apiguardian:apiguardian-api:pom:1.1.0 from/to aliyunmaven (https://maven.aliyun.com/repository/public): maven.aliyun.com: 未知的名称或服务: Unknown host maven.aliyun.com: 未知的名称或服务

【解决】
[root@localhost ~]# vim /opt/mall-swarm-master/pom.xml

                    <executions>
                        <execution>
                            <id>build-image</id>
                            <phase>package</phase>
                            <goals>
                                <goal>build</goal>
                            </goals>
                        </execution>

【报错】
Failed to execute goal com.spotify:docker-maven-plugin:1.2.2:build (default-cli) on project mall-common: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: com.spotify.docker.client.shaded.org.apache.http.conn.HttpHostConnectException: Connect to 192.168.4.114:2376 [/192.168.4.114] failed: 拒绝连接 (Connection refused) -> [Help 1]
【解决】查看2376端口
\cp /usr/lib/systemd/system/docker.service /usr/lib/systemd/system/docker.service.`date  +%Y-%m-%d-%T`
sed -i "s/ExecStart/#ExecStart/g"  /usr/lib/systemd/system/docker.service
sed -i '11i ExecStart=/usr/bin/dockerd \\' /usr/lib/systemd/system/docker.service
sed -i '12i --tlsverify \\' /usr/lib/systemd/system/docker.service
sed -i '13i --tlscacert=/etc/docker/ca.pem \\' /usr/lib/systemd/system/docker.service
sed -i '14i --tlscert=/etc/docker/server-cert.pem \\' /usr/lib/systemd/system/docker.service
sed -i '15i --tlskey=/etc/docker/server-key.pem \\' /usr/lib/systemd/system/docker.service
sed -i '16i -H tcp://0.0.0.0:2376 \\' /usr/lib/systemd/system/docker.service
sed -i '17i -H unix:///var/run/docker.sock \' /usr/lib/systemd/system/docker.service
echo -e '\033[41;36m docker配置文件修改成功\033[0m'

#查看
cat /usr/lib/systemd/system/docker.service

#加入仓库地址
cat  >/etc/docker/daemon.json<<EOF
{"insecure-registries":["https://$SERVER"]}
EOF

# 重新加载文件
systemctl daemon-reload
systemctl restart docker.service
systemctl status docker.service
echo -e '\033[41;36m docker重启完毕033[0m'
#直接使用docker-maven-plugin打包试试,由于我们的插件版本有点低,使用新一点版本的Docker会出现如下问题,升级到1.2.2版本解决该问题;

[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.1.0:build (build-image) on project mall-tiny-docker: Exception caught: com.spotify.docker.client.shaded.com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `com.spotify.docker.client.messages.RegistryAuth` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('desktop')
[ERROR] at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: java.util.LinkedHashMap["credsStore"])
[ERROR] -> [Help 1]

#修改完版本后打包,发现TLS不再支持http了,需要改用https,修改<dockerHost>配置为https;
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.2.2:build (build-image) on project mall-tiny-docker: Exception caught: Request error: GET http://192.168.3.101:2375/version: 400, body: Client sent an HTTP request to an HTTPS server. HTTP 400 Bad Request -> [Help 1]

#修改完成后再次打包,继续失败,需要添加对应的客户端证书才能访问;

[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.2.2:build (build-image) on project mall-tiny-docker: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]

#将如下文件复制到指定目录,这里复制到了I:\developer\env\docker-ca;
ca.pem CA证书
cert.pem 客户端证书
key.pem 客户端证书私钥
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
### 回答1: mall商城项目建表语句通常需要包括以下几个方面的表: 1. 用户表:包含用户的基本信息,如用户ID、用户名、密码、手机号码、性别等。 示例建表语句: CREATE TABLE `user` ( `user_id` INT PRIMARY KEY AUTO_INCREMENT, `username` VARCHAR(50) NOT NULL, `password` VARCHAR(50) NOT NULL, `phone` VARCHAR(20), `gender` CHAR(1) ); 2. 商品表:包含商品的基本信息,如商品ID、商品名称、商品描述、价格、库存等。 示例建表语句: CREATE TABLE `product` ( `product_id` INT PRIMARY KEY AUTO_INCREMENT, `product_name` VARCHAR(100) NOT NULL, `description` TEXT, `price` DECIMAL(10,2) NOT NULL, `stock` INT NOT NULL ); 3. 订单表:记录用户的订单信息,包括订单ID、订单时间、用户ID、商品ID、购买数量等。 示例建表语句: CREATE TABLE `order` ( `order_id` INT PRIMARY KEY AUTO_INCREMENT, `order_time` DATETIME NOT NULL, `user_id` INT, `product_id` INT, `quantity` INT, FOREIGN KEY (`user_id`) REFERENCES `user`(`user_id`), FOREIGN KEY (`product_id`) REFERENCES `product`(`product_id`) ); 4. 购物车表:记录用户的购物车信息,包括购物车ID、用户ID、商品ID、添加时间等。 示例建表语句: CREATE TABLE `cart` ( `cart_id` INT PRIMARY KEY AUTO_INCREMENT, `user_id` INT, `product_id` INT, `add_time` DATETIME, FOREIGN KEY (`user_id`) REFERENCES `user`(`user_id`), FOREIGN KEY (`product_id`) REFERENCES `product`(`product_id`) ); 以上是mall商城项目的建表语句示例,根据实际需求和业务逻辑可能还需要添加其他表和字段。建表时需要考虑数据类型、主键、外键等约束,以确保数据的完整性和一致性。 ### 回答2: mall商城项目是一个电子商务项目,建立数据库表可以用于存储和管理商城中的商品、用户、订单等信息。以下是mall商城项目建表语句的示例: 1. 商品表 CREATE TABLE `product` ( `id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(100) NOT NULL, `description` TEXT, `price` DECIMAL(10,2) NOT NULL, `stock` INT NOT NULL, `category_id` INT NOT NULL, PRIMARY KEY (`id`), FOREIGN KEY (`category_id`) REFERENCES `category`(`id`) ); 2. 用户表 CREATE TABLE `user` ( `id` INT NOT NULL AUTO_INCREMENT, `username` VARCHAR(50) NOT NULL, `password` VARCHAR(50) NOT NULL, `email` VARCHAR(100) NOT NULL, `phone` VARCHAR(20) NOT NULL, `address` VARCHAR(100), PRIMARY KEY (`id`), UNIQUE KEY (`username`) ); 3. 订单表 CREATE TABLE `order` ( `id` INT NOT NULL AUTO_INCREMENT, `user_id` INT NOT NULL, `product_id` INT NOT NULL, `quantity` INT NOT NULL, `amount` DECIMAL(10,2) NOT NULL, `status` VARCHAR(20) NOT NULL, `order_date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`), FOREIGN KEY (`user_id`) REFERENCES `user`(`id`), FOREIGN KEY (`product_id`) REFERENCES `product`(`id`) ); 4. 分类表 CREATE TABLE `category` ( `id` INT NOT NULL AUTO_INCREMENT, `name` VARCHAR(50) NOT NULL, PRIMARY KEY (`id`) ); 以上是mall商城项目建表语句的示例,可以根据实际需求进行修改和扩展。通过这些表,可以存储商品信息,用户信息,订单信息以及分类信息,实现商城项目的功能。 ### 回答3: 在mall商城项目中,建表语句的主要目的是创建数据库的表格,以存储和管理商城的各种数据信息。以下是一个简单的示例: 1. 用户表(user) CREATE TABLE `user` ( `id` INT(11) PRIMARY KEY AUTO_INCREMENT, `username` VARCHAR(50) NOT NULL, `password` VARCHAR(50) NOT NULL, `email` VARCHAR(100) NOT NULL, `phone` VARCHAR(20) NOT NULL, `address` VARCHAR(200) ); 2. 商品表(product) CREATE TABLE `product` ( `id` INT(11) PRIMARY KEY AUTO_INCREMENT, `name` VARCHAR(100) NOT NULL, `price` DECIMAL(10, 2) NOT NULL, `description` VARCHAR(200), `category_id` INT(11), `brand_id` INT(11), `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ); 3. 购物车表(cart) CREATE TABLE `cart` ( `id` INT(11) PRIMARY KEY AUTO_INCREMENT, `user_id` INT(11) NOT NULL, `product_id` INT(11) NOT NULL, `quantity` INT(11) NOT NULL, `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ); 4. 订单表(order) CREATE TABLE `order` ( `id` INT(11) PRIMARY KEY AUTO_INCREMENT, `user_id` INT(11) NOT NULL, `total_price` DECIMAL(10, 2) NOT NULL, `shipping_address` VARCHAR(200) NOT NULL, `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ); 以上是mall商城项目常见的建表语句示例,根据具体需求和项目设计,还可以添加更多表格和字段来存储其他相关信息,如商品分类表、品牌表、评价表等。建表语句应根据具体的项目需求进行调整和完善。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

烟雨话浮生

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

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

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

打赏作者

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

抵扣说明:

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

余额充值