yml配置文件读取出错 Exception in thread "main" while scanning for the next token found character '\t(TAB)'
这几天在学习springboot的微服务项目,在配置文件方面也想尝试下新的yml配置,就想把原来项目properties写的文件转换成yml试一下(老项目是之前检出在了eclipse里面),结果写好了yml配置文件,项目启动时候报了如下错误:
Exception in thread "main" while scanning for the next token
found character '\t(TAB)' that cannot start any token. (Do not use \t(TAB) for indentation)
in 'reader', line 9, column 3:
dubbo:
^
at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:420)
at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:226)
.......
原因是因为我在yml配置文件中用了Tab键来缩进,所以导致spring启动读取yml配置文件不能正确读取。
注意我在上面标红的地方,yml配置中使用Tab来缩进确实不符合yml的语法规则,但是我试了一下在另一个开发工具IDEA中yml配置使用Tab来缩进项目启动是没有报错的,可能是是IDEA开发工具比较厉害的一点,不过我们还是要注意尽量不要使用Tab来缩进。
还有很多类似的启动报错,很可能就是你的yml配置文件里面有问题,这个时候我们就要仔细检查下yml文件书写是否符合规范,贴一个YAML语言教程地址:http://www.ruanyifeng.com/blog/2016/07/yaml.html?f=tt
里面有写yml文件的语法规则,大家可以去看看。
上面是可以从代码报错中看出,当时我的项目中报错如下:
Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning a simple key
in 'reader', line 7, column 3:
serviceUrl.defaultZone:http://lo ...
^
could not find expected ':'
in 'reader', line 7, column 55:
... ne:http://localhost:8080/eureka/
^
改正方法:yml文件中key: value,在value之前加上空格,我的代码是eureka.client.serviceUrl.defaultZone: http://localhost:8080/eureka/
ok
yml配置文件读取出错 Exception in thread "main" while scanning for the next token found character '\t(TAB)'的更多相关文章
- 启动elasticsearch的时候报出Exception in thread "main" SettingsException[Failed to load settings from /usr/local/elasticsearch/config/elasticsearch.yml]; nested: MarkedYAMLException[while scanning a simple ke
故障现象: [elasticsearch@tiantianml- ~]$ /usr/local/elasticsearch/bin/elasticsearch Exception in thread ...
- grails框架中读取txt文件内容将内容转换为json格式,出现异常Exception in thread "main" org.json.JSONException: A JSONObject text must begin with '{' at character 1 of [...]
Exception in thread "main" org.json.JSONException: A JSONObject text must begin with '{' a ...
- Exception in thread "main" SettingsException[Failed to load settings from [elasticsearch.yml]]; nested: ElasticsearchParseException[malformed, expected end of settings but encountered additional conte
D:\elasticsearch\elasticsearch-2.4.0\bin>elasticsearchException in thread "main" Settin ...
- Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space解决方法 问题描述 Exception ...
- Exception in thread "main" java.nio.channels.NotYetConnectedException
import java.nio.channels.AsynchronousServerSocketChannel; import java.nio.channels.AsynchronousSocke ...
- Exception in thread "main" java.lang.OutOfMemoryError: Java heap space(Java堆空间内存溢出)解决方法
http://hi.baidu.com/619195553dream/blog/item/be9f12adc1b5a3e71f17a2e9.html问题描述Exception in thread &q ...
- ERROR: Field 'PostId' doesn't have a default value Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not execute statement
例子: Post p = new Post(); p.setPostId(3); p.setPostName("技术"); 在执行数据保持时提示session.save(p); 的 ...
- 在运行Hibernate Hello World程序的时候,抛如下错误: view plain Exception in thread "main" org.hibernate.exception.LockAcquisitionException 解决方法
在运行Hibernate Hello World程序的时候,抛如下错误: Exception in thread "main" org.hibernate.exception.Lo ...
- Java中调用c/c++语言出现Exception in thread "main" java.lang.UnsatisfiedLinkError: Test.testPrint(Ljava/lang/String;)V...错误
错误: Exception in thread "main" java.lang.UnsatisfiedLinkError: Test.testPrint(Ljava/lang/S ...
随机推荐
- 使用 dom4j 处理 xml (2)
记录一些 xpath 的常规用法,备忘. //3.XPath 了解(用于在xml中选取元素,类似 jquery 选择器) //3.1 路径 Node node1 = root.selectSingle ...
- Color Schema 配色随笔
附pdf文件: ColorSchema.pdf
- CentOS7运行报错kernel:NMI watchdog: BUG: soft lockup - CPU#0 stuck for 26s
CentOS内核,对应的文件是/proc/sys/kernel/watchdog_thresh.CentOS内核和标准内核还有一个地方不一样,就是处理CPU占用时间过长的函数,CentOS下是watc ...
- vue配置手机通过IP访问,Win10让局域网内其他电脑通过IP访问网站的方法
vue配置手机通过IP访问config/index.js// Various Dev Server settings host: '0.0.0.0', // can be overwritten by ...
- 使用GoldenGate EVENTACTIONS执行数据的实时触发和定制化
Oracle GoldenGate不仅可以在线实时同步数据(包括增量和存量),也内置有一套事件触发流程,允许用户根据某张表某条记录的某个特殊字段值,触发相应的自定义执行流程,比如接收到某个银行账号的大 ...
- Automatically populating $HTTP_RAW_POST_DATA is deprecated......
Automatically populating $HTTP_RAW_POST_DATA is deprecated... 1 这个问题和PHP版本有关系,PHP 5.6已经废弃了$HTTP_RAW_ ...
- VC++ 实现程序重启
转载:https://blog.csdn.net/what951006/article/details/72729448 一.创建一个Win32项目 二.窗口处理函数中,Create窗口时创建一个按钮 ...
- 使用proces explorer查看系统gdi
用mfc开发,使用双缓冲刷新屏幕时,可能会造成GDI的增长,当增长到一定数量[10000]时,软件会崩,可以通过 proces explorer来监测GDI,调试代码 打开proces explore ...
- 【BUAA-OO】第一单元作业总结
#OO第一单元作业总结 #确认存活,爱学习,爱北航,爱OO 一.三次作业分析 1.第一次作业 1.1 程序结构 对方法的度量: 类的内聚和相互间的耦合情况: 类图: 优缺点: 优点大概没什么优点,毕竟 ...
- hp quicktestprofession ver-10.0(QTP)的入门使用指南
---恢复内容开始--- SQA(software quality assurance) tool hp quicktestprofession ver-10.0(QTP) environment w ...