谷粒商城end项目过程中遇到的问题

未解决的问题

pms_attr 可能缺少一个字段

在后台管理系统的,商品系统–平台属性–规格参数(基本属性),有一个多选的参数值类型,可以指定该基本属性是否支持多选

在发布商品的时候,基本属性可以根据值类型,决定该基本属性的值是否多选,

理论上,这样的操作是需要在数据库定义一个字段,动态获取的,但是数据库没有该字段

而且,我复制的前端页面也没有实现该功能,故暂时把该问题定义为暂时不能解决的问题,如果不影响后续操作,该问题不解决。

路由无法跳转 product-attrupdate

在商品系统-商品维护-spu管理,规格是要路由到product-attrupdate,结果路由不过去,

我对这块儿实在是不太了解,无从下手

静态资源资源最后放在项目里

在搭建product和search服务时,使用nginx做了动静分离,这时idea项目本身就缺少文件了,不利于后来的人看项目,所以项目做的差不多的时候,看看怎么能弄回来吧

todo谷粒商城二本地虚拟机环境搭建及项目初始化

renren-fast报java找不到符号

项目无任何报错,只有找不到符号

解决是将lombok.version由1.18.4升级为1.18.14

java找不到符号这个问题一共出现过两三次

  1. idea弄错了项目结构,需要重新导入一下项目,在file - Project Structure - Modules,把所有模块全部干掉,再重新导入,然后maven clean,idea rebuild project

  2. lombok版本不对或者太低

  3. 因为maven依赖传递优先级的原因,模块统一依赖了common模块,但lombok依然会使用springboot指定的lombok版本,这就导致了common与其他模块lombok版本的不一致,修改common模块lombok的版本为springboot的版本即可

谷粒商城三分布式组件-SpringCloud Alibaba

Spring Cloud 2020版本 bootstrap 配置文件(properties 或者 yml)无效

背景

微服务是基于Spring Cloud框架搭建的,Spring Cloud Config作为服务配置中心。

业务服务只配置服务名称、启用环境和config的URL地址,其他都配置在配置中心,例如服务端口、服务注册中心地址等。可在开发环境(dev)、测试环境(test)和生产环境(prod)分别配置。

所以预想的启动流程是:先加载配置文件,再启动服务。

之前的做法是,将配置文件名称改为:bootstrap.properties。

问题

之前直接就可以用,而现在,启动的端口是8080,明显没有加载到bootstrap.properties文件,我以为我的文件名字写错了,核对了几次,确认无误,我猜想估计是bootstramp.properties配置文件没有生效。

之前的版本:

spring boot 2.3.1.RELEASE

spring cloud Hoxton.SR4

当前版本:

spring boot 2.5.5

spring cloud 2020.0.4

原因

根据上面出现的问题,我使用百度搜索了下,大概的原因知道了:从Spring Boot 2.4版本开始,配置文件加载方式进行了重构。

另外也有配置的默认值变化,如下:

Spring Boot 2.3.8.RELEASE

package org.springframework.cloud.bootstrap;

	public class BootstrapApplicationListener implements ApplicationListener<ApplicationEnvironmentPreparedEvent>, Ordered {
		public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
			ConfigurableEnvironment environment = event.getEnvironment();
        	if ((Boolean)environment.getProperty("spring.cloud.bootstrap.enabled", Boolean.class, true)) {

Spring Boot 2.4.2

package org.springframework.cloud.util;

	public abstract class PropertyUtils {
    	public static boolean bootstrapEnabled(Environment environment) {
        	return (Boolean)environment.getProperty("spring.cloud.bootstrap.enabled", Boolean.class, false) || MARKER_CLASS_EXISTS;
    }

传统解决方案:

其实官网说得很明白。看下面这段:

Config First Bootstrap

To use the legacy bootstrap way of connecting to Config Server, bootstrap must be enabled via a property or the spring-cloud-starter-bootstrap starter. The property is spring.cloud.bootstrap.enabled=true. It must be set as a System Property or environment variable. Once bootstrap has been enabled any application with Spring Cloud Config Client on the classpath will connect to Config Server as follows: When a config client starts, it binds to the Config Server (through the spring.cloud.config.uri bootstrap configuration property) and initializes Spring Environment with remote property sources.

要使用传统的引导方式连接到Config Server,必须通过一个属性或spring-cloud-starter-bootstrap启动器启用引导。 这个属性是spring.cloud.bootstrap.enabled=true。 它必须设置为系统属性或环境变量。 一旦启动了引导,类路径上的任何带有Spring Cloud Config Client的应用程序都将连接到Config Server,如下所示:当一个配置客户端启动时,它绑定到Config Server(通过Spring . Cloud . Config .uri引导配置属性),并使用远程属性源初始化Spring Environment。

The net result of this behavior is that all client applications that
want to consume the Config Server need a bootstrap.yml (or an
environment variable) with the server address set in
spring.cloud.config.uri (it defaults to “http://localhost:8888”).
这种行为的最终结果是所有的客户端应用程序
想要使用配置服务器需要一个引导程序。 yml(或一个
环境变量),并设置服务器地址
spring.cloud.config.uri(默认为“http://localhost:8888”)。

两个关键点:

  1. 加一个依赖:spring-cloud-starter-bootstrap
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
  1. 加一个配置:spring.cloud.config.uri

bootstrap.properties

# 应用名称
spring.application.name=erwin-cloud-user
# 启用环境
spring.profiles.active=dev

# 配置文件
spring.cloud.config.label=${spring.application.name}
spring.cloud.config.name=${spring.application.name}
spring.cloud.config.profile=${spring.profiles.active}
spring.cloud.config.uri=http://localhost:9000

现在解决方案

application.properties

# 应用名称
spring.application.name=erwin-cloud-user
# 启用环境
spring.profiles.active=dev

spring.config.import=optional:configserver:http://localhost:9000

spring.cloud.config.label=${spring.application.name}
spring.cloud.config.name=${spring.application.name}
spring.cloud.config.profile=${spring.profiles.active}

我自己解决的是:

bootstrap.properties

spring.application.name=gulistore-coupon
spring.cloud.nacos.config.server-addr=127.0.0.1:8848

然后再添加spring-cloud-starter-bootstrap依赖就可以了

idea报找不到或无法加载主类

我出的问题可能是我不知道什么时候改了哪儿的模块的名字,总之是项目结构上的问题

解决

file—>Project Structure——>Moudles—>点击减号将所有的Moudle删除—>点击+号重新引入Moudle(直接引入父类的pom即可)

最后Rebuild Project

启动商品服务报无法连接redis

Error creating bean with name ‘enableRedisKeyspaceNotificationsInitializer’ defined in class path resource

之前是可以的,不知道是不是因为rabbitmq换了一下mvn的仓库版本导致的

经查找,在Java代码中,我们使用了注解:@EnableRedisHttpSession,这个注解是用来开启Redis来集式式管理Session。

而在使用这种方式的时候,是需要Redis开启Keyspace Notifications功能的,默认是关闭的。
这个功能有一个参数来控制它,notify-keyspace-events,值为Egx。可以通过在Redis.Config中配置。也可以通过命令行来配置,如下所示:
redis-cli config set notify-keyspace-events Egx
然后重启Redis生效。

需要有时间看的知识

  1. 学习JSR303(java规范第303号相关标准)springboot提供的
  2. 学习Bigdecimal
  3. 分析一下apachecommon、spring、nacos的StringUtils有什么区别

八、人人项目-逆向工程

部分内容转载自:https://blog.csdn.net/qq_28336351/article/details/113730679
https://blog.csdn.net/l_mloveforever/article/details/112725753?utm_medium=distribute.pc_relevant.none-task-blog-2defaultbaidujs_baidulandingword~default-0-112725753-blog-122468216.t5_landing_title_tags_v2&spm=1001.2101.3001.4242.1&utm_relevant_index=3

https://blog.csdn.net/luck_sheng/article/details/114362908

春节,我回家,每天早上还醒不过来,母亲已经起床。在屋子里收拾东西,走来走去,一边絮絮叨叨与我说话。说的都是家里的事情,如同童年回忆里一样。我信任所有真实自然的语言,没有矫饰,没有虚浮,有的只是在生活和情感中的逐渐沉淀。没有什么比一个人对自己自然真实地说话,更为令人觉得安全。语言,此刻提供的是一种感情的凭证。代表着延展,代表着继续。没有完结。

素年锦时
安妮宝贝

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值