学成在线项目异常

Day01

1 出现本地仓库的包存在,但是pom文件找不到

解决方式:首先打开IDEA中的Maven设置,勾选work offline,将仓库中目录中的__remote.repositories文件全部删除,此时还不行,发现重新手敲依赖代码,pom文件文件依赖不再爆红,还有spring-cloud-starter-feign这个没有添加版本,添加版本即可。

2 <relativePath>../xc-framework-parent/pom.xml</relativePath>标签内容为红色

解决方式:应该是因为子工程并没有放到父工程下,所以导致出现警告,但是按照讲义,这个子工程确实没有放到父工程下,只是在pom中声明了父工程,这个没解决,但是好像不影响项目。

Day02

3 出现 sh: webpack‐dev‐server: command not found 异常

解决方式:将nodejs以及webpack换成文档所使用的版本,将npm_modules删除,重新执行安装命令。还有一种可能是从文档拷贝到IDE中的代码格式有问题,手敲一遍。自己解决也有点稀了糊涂,弄了一遍,不好使,然后重新弄了一遍就好使了,也有可能是IDE提醒要```npm install```一下。

4 Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.configuration.entry should be one of these:

首先在build/webpack.dev.conf.js文件中devServer: {}中添加```inline: false,```。然后在终端npm uninstall webpack-dev-server@3.9.1,  npm install install webpack-dev-server

5 internal/child_process.js:340 throw errnoException(err, 'spawn');

在根目录下打开终端运行命令 chmod -R u+x .

6 Node Sass could not find a binding for your current environment: OS X 64-bit with Node.js 9.x Found bindings for the following environments:Windows 64-bit with Node.js 9.x.......

参考链接:https://www.cnblogs.com/shanidea/p/11792196.html
问题原因:
MacOS 下 node-sass 编译没通过,导致 node-sassvendordarwin-x86-59 目录下缺少 binding.node 文件。
解决办法:
解决方法一:执行命令```npm rebuild node-sass```,即从新编译 node-sass 即可。
注意:前提是--安装python,并拥有python环境!
解决方法二(本人本项目所使用的解决方法):
问题原因:
由于..
ode-sassvendordarwin-x86-59inding.node文件的版本缺失,导致出现报错。
本人的电脑系统是MacOS,而资料的代码开发在windows平台下,系统报错在darwin-x64-59目录下缺少binding.node文件,使用以下命令查看对应的版本```node -p "[process.platform, process.arch, process.versions.modules].join('-')"```,所以去官网https://github.com/sass/node-sass/releases下载相应版本的 binding.node 文件。并放入到报错项目的 node-sassvendor文件夹下(注意下载的是.node文件,不要下载错),如:我的系统需要下载的 darwin-x64-59_binding.node 文件,下载之后将该文件重命名为 binding.node 后放入到 node-sassvendordarwin-x64-59 目录下即可。最后:运行成功。

Day03

6 "JSON parse error: Cannot deserialize value of type java.util.Date from String "2018‐06‐11T02:01:25.667Z": expected format "yyyy-MM-dd'T'HH:mm:ss.SSSZ";

JSON parse error: Cannot deserialize instance of java.lang.String out of START_ARRAY token;

修改json数据pageCreateTime为"2020-02-06T07:34:21.255Z"

7 JSON parse error: Cannot deserialize instance of java.lang.String out of START_ARRAY token;

"pageParameter": [{
        "pageParamName": "string",
        "pageParamValue": "string"
    }]
使用这个测试,会报错,所以还是先修改为"pageParameter":"string"

8"export 'page_add' (imported as 'cmsApi') was not found in '../api/cms'

因为cms.js中没有定义page_add ,所以先定义一个空的,之后需要什么功能再填写即可。
export const page_add = () => {

}

Day04

9 "Field restTemplate in com.xuecheng.test.freemarker.controller.FreemarkerController required a bean of type 'org.springframework.web.client.RestTemplate' that could not be found."

Spring Boot >= 1.4
Spring Boot no longer automatically defines a RestTemplate but instead defines a RestTemplateBuilder allowing you more control over the RestTemplate that gets created. You can inject the RestTemplateBuilder as an argument in your @Bean method to create a RestTemplate:

@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
   // Do any additional configuration here
   return builder.build();
}

Using it in your class

@Autowired
private RestTemplate restTemplate;

10 " “Circular view path” exception with Spring MVC test"

首先注意使用@Controller不是@RestControll,然后还不行,就是freemarker包导入有问题,本工程解决该问题,是将parent工程的freemark版本移除,直接在freemarker工程下的pom文件中添加freemarker版本。

Day04

11 "出现无法注入RabbitTemplate"

在Producer05_topics_springboot类上添加SpringBootApplication。

12 "Unable to find a @SpringBootConfiguration when doing a JpaTest"

将Rabbitmq中的交换机删除,重新运行程序即可。

Day07

13 出现使用Jpa的findById查不到数据库数据。

public CourseMarket getCourseMarketById(String courseId) {
        Optional<CourseMarket> optional = courseMarketRepository.findById(courseId);
        if (optional.isPresent()) {//在这之前有一个!,找到半天错误才找到因为逻辑取反导致出错
            return optional.get();
        }
        return null;
}

Day10

14 Elasticsearch error: cluster_block_exception FORBIDDEN/12/index read-only / allow delete (api)], flood stage disk watermark exceeded异常

使用postman

PUT      localhost:9200/_cluster/settings
{
  "transient":{
    "cluster.routing.allocation.disk.watermark.low":"90%"
  }
}

原因就是电脑内存不够了,修改最低内存为90%,不想弄可以换个大内存电脑^_^。
如果还不行,就是电脑内存剩的少于百分之10了,用如下方式解决:

PUT localhost:9200/_settings
{
    "index": {
        "blocks": {
            "read_only_allow_delete": "false"
        }
    }
}

发现每次给9200端口发送请求都需要设置一下。

原文地址:https://www.cnblogs.com/artwalker/p/13368397.html