黑马头条 各种踩坑合集 从0到1 欢迎留言提问

《黑马头条》SpringBoot+SpringCloud+ Nacos等企业级微服务架构项目_黑马头条项目_软工菜鸡的博客-CSDN博客

各位爷,完整项目gitee如下,求star

heima-leadnews-master: 《黑马头条》项目采用的是SpringBoot+springcloud当下最流行的微服务为项目架构,配合spring cloud alibaba nacos作为项目的注册和配置中心。新课程采用快速开发的模式,主要解决真实企业开发的一些应用场景。详情请看博客:https://blog.csdn.net/m0_67184231/article/details/131439819

Day01

用他的 centos镜像 自动集成了 nacos 所有的配置 大部分都要改mysql密码啥的;

启动他的项目,有些时候要启动 redis 容器;镜像里面已经拉取好了;

直接输入
docker run -d --name redis --restart=always -p 6379:6379 redis --requirepass "leadnews";

也可以看P84

Resource的logback都要改成对应的

读取C:\Users\{用户}\.m2\repository\org\lz4\lz4-java\1.7.1\lz4-java-1.7.1.jar时出错; error in opening zip file

这个jar包 重新去官网下载一遍:
https://mvnrepository.com/artifact/org.lz4/lz4-java/1.7.1

day02

黑马头条 各种踩坑合集 从0到1 欢迎留言提问_第1张图片

Minio的模版有问题显示不正确!

黑马头条 各种踩坑合集 从0到1 欢迎留言提问_第2张图片

他这里要导入basic微服务;才能引入file-starter

黑马头条 各种踩坑合集 从0到1 欢迎留言提问_第3张图片

这个要在nacos里面配 minio;

黑马头条 各种踩坑合集 从0到1 欢迎留言提问_第4张图片

黑马头条 各种踩坑合集 从0到1 欢迎留言提问_第5张图片

?allowPublicKeyRetrieval=true  成功解决;

黑马头条 各种踩坑合集 从0到1 欢迎留言提问_第6张图片

day03 文章发布

上来就有坑,还好我发现的早,脚本中没有建库语句,去day2拿过来改改

启动WemediaAplication.java微服务

day03的项目 还得开本地redis;不然报错

WARN  o.s.b.a.r.RedisReactiveHealthIndicator - Redis health check failed

org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to localhost:6379

at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$ExceptionTranslatingConnectionProvider.translateException(LettuceConnectionFactory.java:1534)

at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$ExceptionTranslatingConnectionProvider.getConnection(LettuceConnectionFactory.java:1442)

点击 收藏 功能 报错;

黑马头条 各种踩坑合集 从0到1 欢迎留言提问_第7张图片

黑马头条 各种踩坑合集 从0到1 欢迎留言提问_第8张图片

查了一下,71 代表id;自己写了一个方法加在:WmMaterialController.java

 @GetMapping("/collect/{id}")
    public ResponseResult collect(@PathVariable Long id){

        if(id==null)
            return ResponseResult.errorResult(0,"传输的收藏id为空");

        WmMaterial wmMaterial = wmMaterialService.getById(id);
//        System.out.println(wmMaterial);
        wmMaterial.setIsCollection((short) 1);
        wmMaterialService.updateById(wmMaterial);

        return ResponseResult.okResult(wmMaterial);
    }

运行成功!我真牛逼!

哦,原来是day3的作业;没给答案  但是全自己做完了捏

黑马头条 作业+解答 day03-自媒体文章发布 自媒体接口_软工菜鸡的博客-CSDN博客

文章管理 发布文章的业务WmNewsServiceImpl.java

这里少了一个问题——没有判断文章内部如果没有图片的情况!

我测验 发现 他应该是在前端实现了;不管是自动还是无图,都会加系统的默认图片;

day04

ApArticleServiceImpl.java的

saveArticle() 这个2.2方法缺少两行黄色背景的代码 判空的Bug;传入错误的id得不到apArticleContent

else {
    //2.2 存在id   修改  文章  文章内容
    //修改  文章
    updateById(apArticle);
    //修改文章内容
    ApArticleContent apArticleContent = apArticleContentMapper.selectOne(Wrappers.lambdaQuery()
            .eq(ApArticleContent::getArticleId, dto.getId()));
    if(apArticleContent==null)//传的id不对的话 这个位置为null会报错
        return ResponseResult.errorResult(PARAM_REQUIRE);
    apArticleContent.setContent(dto.getContent());
    apArticleContentMapper.updateById(apArticleContent);
}

黑马头条 各种踩坑合集 从0到1 欢迎留言提问_第9张图片

这里出错的原因是没有jwt;重新启动项目,没刷新页面就直接点击功能了;报处理异常;

我的想法是在jwt验证里 加个抛出异常的提醒;

黑马头条 各种踩坑合集 从0到1 欢迎留言提问_第10张图片

黑马头条 各种踩坑合集 从0到1 欢迎留言提问_第11张图片

没看出来 成没成功;

内容安全,自动审核的东西大部分都没有测出效果,阿里云的接口换了 没用;

黑马头条 各种踩坑合集 从0到1 欢迎留言提问_第12张图片

审核图片失败 说是图片下载不下来;

黑马头条 各种踩坑合集 从0到1 欢迎留言提问_第13张图片

审核文本失败  我直接注释了

WmNewsAutoScanServiceImpl.java 的clientBean要加@Qualifier限定符 

不然两个Client找不到用哪个

@Qualifier("com.heima.apis.article.IArticleClient")
@Autowired
private IArticleClient articleClient;

黑马头条 各种踩坑合集 从0到1 欢迎留言提问_第14张图片

测试了一下 源码不能检测 标题的敏感词汇;加了个这:  wmNews.getTitle()+

//自管理的敏感词过滤
boolean isSensitive = handleSensitiveScan(
        wmNews.getTitle()+textAndImages.get("content"), wmNews);

P77生成静态文件失败

Day04 作业

黑马头条 各种踩坑合集 从0到1 欢迎留言提问_第15张图片

黑马头条 各种踩坑合集 从0到1 欢迎留言提问_第16张图片

Day05

测试连接redis

端口有问题

黑马头条 各种踩坑合集 从0到1 欢迎留言提问_第17张图片

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'scheduleClient': Unsatisfied dependency expressed through field 'taskService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'taskServiceImpl': Invocation of init method failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:

### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Public Key Retrieval is not allowed

### The error may exist in com/heima/schedule/mapper/TaskinfoMapper.java (best guess)

### The error may involve com.heima.schedule.mapper.TaskinfoMapper.selectList

### The error occurred

加这个 &allowPublicKeyRetrieval=true

org.springframework.context.ApplicationContextException: Failed to start bean 'org.springframework.kafka.config.internalKafkaListenerEndpointRegistry'; nested exception is java.lang.IllegalStateException: No group.id found in consumer config, container properties, or @KafkaListener annotation; a group.id is required when group management is used.

黑马头条 各种踩坑合集 从0到1 欢迎留言提问_第18张图片

加group-id

Day7

mangoDB的删除,为啥报这个错? 说是要反序列化

org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Problem deserializing property 'id' (expected type: [simple type, class java.lang.String]; actual type: `com.heima.model.search.dtos.HistorySearchDto`), problem: argument type mismatch; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Problem deserializing property 'id' (expected type: [simple type, class java.lang.String]; actual type: `com.heima.model.search.dtos.HistorySearchDto`), problem: argument type mismatch

 at [Source: (PushbackInputStream); line: 1, column: 7] (through reference chain: com.heima.model.search.dtos.HistorySearchDto["id"])

at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:285)

at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.read(AbstractJackson2HttpMessageConverter.java:243)

at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:205)

at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.readWithMessageConverters(RequestResponseBodyMethodProcessor.java:158)

at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:131)

at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:121)

at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:167)

at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:134)

at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)

at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878)

at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792)

at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)

at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)

at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)

at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)

at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:652)

at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

at com.github.xiaoymin.knife4j.spring.filter.ProductionSecurityFilter.doFilter(ProductionSecurityFilter.java:53)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

at com.github.xiaoymin.knife4j.spring.filter.SecurityBasicAuthFilter.doFilter(SecurityBasicAuthFilter.java:90)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:346)

at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)

at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)

at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:887)

at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1684)

at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

at java.lang.Thread.run(Thread.java:750)

Caused by: com.fasterxml.jackson.databind.JsonMappingException: Problem deserializing property 'id' (expected type: [simple type, class java.lang.String]; actual type: `com.heima.model.search.dtos.HistorySearchDto`), problem: argument type mismatch

 at [Source: (PushbackInputStream); line: 1, column: 7] (through reference chain: com.heima.model.search.dtos.HistorySearchDto["id"])

at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:281)

at com.fasterxml.jackson.databind.deser.SettableBeanProperty._throwAsIOE(SettableBeanProperty.java:609)

at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:143)

at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:293)

at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:156)

at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4526)

at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3521)

at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:274)

... 61 more

Caused by: java.lang.IllegalArgumentException: argument type mismatch

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:141)

... 66 more

2023-07-08 21:46:15.130 ERROR 23340 --- [io-51804-exec-4] c.heima.common.exception.ExceptionCatch  : catch exception:JSON parse error: Problem deserializing property 'id' (expected type: [simple type, class java.lang.String]; actual type: `com.heima.model.search.dtos.HistorySearchDto`), problem: argument type mismatch; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Problem deserializing property 'id' (expected type: [simple type, class java.lang.String]; actual type: `com.heima.model.search.dtos.HistorySearchDto`), problem: argument type mismatch

 at [Source: (PushbackInputStream); line: 1, column: 7] (through reference chain: com.heima.model.search.dtos.HistorySearchDto["id"])

黑马头条 各种踩坑合集 从0到1 欢迎留言提问_第19张图片

把21行的id getId打印一下,啥类型 没解决

黑马头条 各种踩坑合集 从0到1 欢迎留言提问_第20张图片

真的逆天,前端传的和HistorySearchDto 类型对不上,改成String,拆JSON得到Id才能删除成功!困扰我两个小时cnm

ApUserSearchController.java

@PostMapping("/del")
public ResponseResult delUserSearch(@RequestBody String dto){
    Map,String> map = JSON.parseObject(dto, Map.class);
    String id = map.get("id");
    return apUserSearchService.delUserSearch(id);
}

Day08

《黑马头条》 ElectricSearch 分词器 联想词 MangoDB day08-平台管理[实战]作业_软工菜鸡的博客-CSDN博客

Day09

黑马头条 Day 09用户行为-需求_软工菜鸡的博客-CSDN博客

Day11

测kafka流消息失败因为 minio的文章框架报错404

黑马头条 各种踩坑合集 从0到1 欢迎留言提问_第21张图片

你可能感兴趣的:(python,开发语言)