现在renren-fast的springboot版本为2.6.6,如果直接引入gulimall-common,会出现springboot版本和springcloud版本不匹配,而且看弹幕和评论区说最好所用版本都和老师的一致,要不然后面出现无数问题。
修改springboot版本为2.1.18.RELEASE,然后单独引入springCloud的nacos,不需要引入gulimall-common
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0modelVersion>
<groupId>io.renrengroupId>
<artifactId>renren-fastartifactId>
<version>3.0.0version>
<packaging>jarpackaging>
<description>renren-fastdescription>
<parent>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-parentartifactId>
<version>2.1.18.RELEASEversion>
parent>
<properties>
<project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8project.reporting.outputEncoding>
<java.version>1.8java.version>
<mybatisplus.version>3.3.1mybatisplus.version>
<mysql.version>8.0.28mysql.version>
<mssql.version>4.0mssql.version>
<oracle.version>11.2.0.3oracle.version>
<druid.version>1.1.13druid.version>
<quartz.version>2.3.0quartz.version>
<commons.lang.version>2.6commons.lang.version>
<commons.fileupload.version>1.2.2commons.fileupload.version>
<commons.io.version>2.5commons.io.version>
<commons.codec.version>1.10commons.codec.version>
<commons.configuration.version>1.10commons.configuration.version>
<shiro.version>1.9.0shiro.version>
<jwt.version>0.7.0jwt.version>
<kaptcha.version>0.0.9kaptcha.version>
<qiniu.version>7.2.23qiniu.version>
<aliyun.oss.version>2.8.3aliyun.oss.version>
<qcloud.cos.version>4.4qcloud.cos.version>
<swagger.version>2.7.0swagger.version>
<joda.time.version>2.9.9joda.time.version>
<gson.version>2.8.5gson.version>
<fastjson.version>1.2.79fastjson.version>
<hutool.version>4.1.1hutool.version>
<lombok.version>1.18.4lombok.version>
<service-path>/work/renrenservice-path>
<pack-name>${project.artifactId}-${project.version}.jarpack-name>
<remote-addr>192.168.1.10:22remote-addr>
<remote-username>rootremote-username>
<remote-passwd>123456remote-passwd>
properties>
<dependencies>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-testartifactId>
<scope>testscope>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-data-redisartifactId>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-webartifactId>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-aopartifactId>
dependency>
<dependency>
<groupId>org.springframeworkgroupId>
<artifactId>spring-context-supportartifactId>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-starter-validationartifactId>
dependency>
<dependency>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-configuration-processorartifactId>
<optional>trueoptional>
dependency>
<dependency>
<groupId>com.baomidougroupId>
<artifactId>mybatis-plus-boot-starterartifactId>
<version>${mybatisplus.version}version>
<exclusions>
<exclusion>
<groupId>com.baomidougroupId>
<artifactId>mybatis-plus-generatorartifactId>
exclusion>
exclusions>
dependency>
<dependency>
<groupId>mysqlgroupId>
<artifactId>mysql-connector-javaartifactId>
<version>${mysql.version}version>
dependency>
<dependency>
<groupId>com.oraclegroupId>
<artifactId>ojdbc6artifactId>
<version>${oracle.version}version>
dependency>
<dependency>
<groupId>com.microsoft.sqlservergroupId>
<artifactId>sqljdbc4artifactId>
<version>${mssql.version}version>
dependency>
<dependency>
<groupId>org.postgresqlgroupId>
<artifactId>postgresqlartifactId>
dependency>
<dependency>
<groupId>com.alibabagroupId>
<artifactId>druid-spring-boot-starterartifactId>
<version>${druid.version}version>
dependency>
<dependency>
<groupId>org.quartz-schedulergroupId>
<artifactId>quartzartifactId>
<version>${quartz.version}version>
<exclusions>
<exclusion>
<groupId>com.mchangegroupId>
<artifactId>c3p0artifactId>
exclusion>
exclusions>
dependency>
<dependency>
<groupId>commons-langgroupId>
<artifactId>commons-langartifactId>
<version>${commons.lang.version}version>
dependency>
<dependency>
<groupId>commons-fileuploadgroupId>
<artifactId>commons-fileuploadartifactId>
<version>${commons.fileupload.version}version>
dependency>
<dependency>
<groupId>commons-iogroupId>
<artifactId>commons-ioartifactId>
<version>${commons.io.version}version>
dependency>
<dependency>
<groupId>commons-codecgroupId>
<artifactId>commons-codecartifactId>
<version>${commons.codec.version}version>
dependency>
<dependency>
<groupId>commons-configurationgroupId>
<artifactId>commons-configurationartifactId>
<version>${commons.configuration.version}version>
dependency>
<dependency>
<groupId>org.apache.shirogroupId>
<artifactId>shiro-coreartifactId>
<version>${shiro.version}version>
dependency>
<dependency>
<groupId>org.apache.shirogroupId>
<artifactId>shiro-springartifactId>
<version>${shiro.version}version>
dependency>
<dependency>
<groupId>io.jsonwebtokengroupId>
<artifactId>jjwtartifactId>
<version>${jwt.version}version>
dependency>
<dependency>
<groupId>com.github.axetgroupId>
<artifactId>kaptchaartifactId>
<version>${kaptcha.version}version>
dependency>
<dependency>
<groupId>io.springfoxgroupId>
<artifactId>springfox-swagger2artifactId>
<version>${swagger.version}version>
dependency>
<dependency>
<groupId>io.springfoxgroupId>
<artifactId>springfox-swagger-uiartifactId>
<version>${swagger.version}version>
dependency>
<dependency>
<groupId>com.qiniugroupId>
<artifactId>qiniu-java-sdkartifactId>
<version>${qiniu.version}version>
dependency>
<dependency>
<groupId>com.aliyun.ossgroupId>
<artifactId>aliyun-sdk-ossartifactId>
<version>${aliyun.oss.version}version>
dependency>
<dependency>
<groupId>com.qcloudgroupId>
<artifactId>cos_apiartifactId>
<version>${qcloud.cos.version}version>
<exclusions>
<exclusion>
<groupId>org.slf4jgroupId>
<artifactId>slf4j-log4j12artifactId>
exclusion>
exclusions>
dependency>
<dependency>
<groupId>joda-timegroupId>
<artifactId>joda-timeartifactId>
<version>${joda.time.version}version>
dependency>
<dependency>
<groupId>com.google.code.gsongroupId>
<artifactId>gsonartifactId>
<version>${gson.version}version>
dependency>
<dependency>
<groupId>com.alibabagroupId>
<artifactId>fastjsonartifactId>
<version>${fastjson.version}version>
dependency>
<dependency>
<groupId>cn.hutoolgroupId>
<artifactId>hutool-allartifactId>
<version>${hutool.version}version>
dependency>
<dependency>
<groupId>org.projectlombokgroupId>
<artifactId>lombokartifactId>
<version>${lombok.version}version>
dependency>
<dependency>
<groupId>com.alibaba.cloudgroupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discoveryartifactId>
dependency>
<dependency>
<groupId>com.alibaba.cloudgroupId>
<artifactId>spring-cloud-starter-alibaba-nacos-configartifactId>
dependency>
dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.alibaba.cloudgroupId>
<artifactId>spring-cloud-alibaba-dependenciesartifactId>
<version>2.1.0.RELEASEversion>
<type>pomtype>
<scope>importscope>
dependency>
dependencies>
dependencyManagement>
<build>
<finalName>${project.artifactId}finalName>
<extensions>
<extension>
<groupId>org.apache.maven.wagongroupId>
<artifactId>wagon-sshartifactId>
<version>2.8version>
extension>
extensions>
<plugins>
<plugin>
<groupId>org.springframework.bootgroupId>
<artifactId>spring-boot-maven-pluginartifactId>
<configuration>
<fork>truefork>
configuration>
plugin>
<plugin>
<groupId>org.apache.maven.pluginsgroupId>
<artifactId>maven-surefire-pluginartifactId>
<configuration>
<skipTests>trueskipTests>
configuration>
plugin>
<plugin>
<groupId>org.codehaus.mojogroupId>
<artifactId>wagon-maven-pluginartifactId>
<version>1.0version>
<configuration>
<fromFile>target/${pack-name}fromFile>
<url>url>
<commands>
<command>kill -9 `ps -ef |grep ${project.artifactId}.jar|grep -v "grep" |awk '{print $2}'`command>
<command> ${service-path}/renren.log 2>&1 & ]]>command>
<command>command>
<command>command>
commands>
<displayCommandOutputs>truedisplayCommandOutputs>
configuration>
plugin>
<plugin>
<groupId>com.spotifygroupId>
<artifactId>docker-maven-pluginartifactId>
<version>0.4.14version>
<configuration>
<imageName>renren/fastimageName>
<dockerDirectory>${project.basedir}dockerDirectory>
<resources>
<resource>
<targetPath>/targetPath>
<directory>${project.build.directory}directory>
<include>${project.build.finalName}.jarinclude>
resource>
resources>
configuration>
plugin>
plugins>
build>
<repositories>
<repository>
<id>publicid>
<name>aliyun nexusname>
<url>https://maven.aliyun.com/repository/public/url>
<releases>
<enabled>trueenabled>
releases>
repository>
repositories>
<pluginRepositories>
<pluginRepository>
<id>publicid>
<name>aliyun nexusname>
<url>https://maven.aliyun.com/repository/public/url>
<releases>
<enabled>trueenabled>
releases>
<snapshots>
<enabled>falseenabled>
snapshots>
pluginRepository>
pluginRepositories>
project>
在进行上一步的修改之后,可能出现maven刷新不报错,代码不爆红,但是一运行就提示说程序包找不到,这样修改一下idea设置就行,即给Delegate IDE build打上勾
我在进行这一步之后就成功了,但是如果还有问题,记得检查一下服务有没有注册成功,如果是注册不成功,需要检查一下配置文件有没有写错
注意后端返回的是accessId,而不是accessid,所以前端也要修改
npm install pubsub-js
import PubSub from 'pubsub-js'
<template>
<div>
<el-cascader
filterable
clearable
placeholder="试试搜索:手机"
v-model="paths"
:options="categorys"
:props="setting"
>el-cascader>
div>
template>
<script>
//这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
//例如:import 《组件名称》 from '《组件路径》';
import PubSub from 'pubsub-js'
export default {
//import引入的组件需要注入到对象中才能使用
components: {},
//接受父组件传来的值
props: {
catelogPath: {
type: Array,
default(){
return [];
}
}
},
data() {
//这里存放数据
return {
setting: {
value: "catId",
label: "name",
children: "children"
},
categorys: [],
paths: this.catelogPath
};
},
watch:{
catelogPath(v){
this.paths = this.catelogPath;
},
paths(v){
this.$emit("update:catelogPath",v);
//还可以使用pubsub-js进行传值
PubSub.publish("catPath",v);
}
},
//方法集合
methods: {
getCategorys() {
this.$http({
url: this.$http.adornUrl("/product/category/list/tree"),
method: "get"
}).then(({ data }) => {
this.categorys = data.data;
});
}
},
//生命周期 - 创建完成(可以访问当前this实例)
created() {
this.getCategorys();
}
};
script>
<style scoped>
style>
{ path: '/product-attrupdate', component: _import('modules/product/attrupdate'), name: 'attr-update', meta: { title: '规格维护', isTab: true } }
可能是电脑本地获取的时间慢了,可以将expireTime设置更大一点,比如说700,不行再设置更大一点
///找出所有skuIds的交集即是要切换到的sku,$(变量):包装成一个JQuery元素
let filterEle = skusList[0];
for (let i = 1; i < skusList.length; i++) {
filterEle = new Array();
filterEle.push($(filterEle).filter(skusList[i])[0]);
}
我这边求出来的 filterEle 最后都是没有定义,于是我改成自己的了
let intersectionArr = getIntersection(skusList)
let filterEle = intersectionArr[0]
function getIntersection(skusList) {
let skus1 = skusList[0];
for (let i = 1; i < skusList.length; i++) {
let skus2 = skusList[i];
skus1 = getIntersectionOfTwoArr(skus1, skus2)
}
return skus1;
};
function getIntersectionOfTwoArr(skus1, skus2) {
let intersectArr = new Array();
for (let i = 0; i < skus1.length; i++) {
for (let j = 0; j < skus2.length; j++) {
if (skus1[i] == skus2[j]) {
intersectArr.push(skus1[i])
}
}
}
return intersectArr;
};
由于比较懒,我使用的是最简单的遍历方式,当然还是存在很大的优化空间的,可以去LeetCode上面寻找相关的题目来学习
部分问题这里没有及时记录到,小伙伴们可以查看视频教程的弹幕和评论找答案啦!
后面的k8s部署,对机器的内存要求比较高,很多小伙伴可能玩不起来,但是也可以学习并记好笔记。希望到后面当你手头有几台服务器的时候,你可以将你的绝世神功使用出来。
感谢尚硅谷的教程,收获颇丰。