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 ...
随机推荐
- 群晖IP地址更新问题
系统:黑群晖 DS3615 事件:初始安装后 会自动获取一个IP地址,各项功能正常,由于网络调整,更换了路由,群晖宿主机链接到了二级路由(交换机模式) 问题: 1.使用原始的IP无法访问到群晖服务 ...
- 【数据结构】算法 LinkList (Add Two Numbers)
两个用链表代表的整数,其中每个节点包含一个数字.数字存储按照在原来整数中相反的顺序,使得第一个数字位于链表的开头.写出一个函数将两个整数相加,用链表形式返回和. Solution:建立一个新链表C,然 ...
- sitecore8.2 基于item路径查询item
查询: query:/sitecore/content/home/foo/bar 结果 bar
- 阿里云 SSL 证书 总结
历时2天左右的证书上传部署,终于结束了! 因为公司要开发小程序,小程序部署到开发环境必须支持https证书行. 阿里云目前的证书还是比较多的额,大致分为2类,一类是支持单域名,一类是支持泛域名. 自己 ...
- left join on +多条件与where区别
left join on +多条件与where区别 重点 先匹配,再筛选where条件. 本文将通过几个例子说明两者的差别. 1. 单个条件 select * from product a left ...
- mysql_study_5
代码 mysql> CREATE TABLE shop ( ) UNSIGNED ZEROFILL ' NOT NULL, ) DEFAULT '' NOT NULL, ,) DEFAULT ' ...
- 【js】箭头函数与普通函数的异同
普通函数在es5中就有了,箭头函数是es6中出现的函数形式,当然也可以继续用es5写法. 普通函数大家知道: 形式基本一致 来看看箭头函数: 开发时根据实际情况可以省略一些东西 单条处理可以省略ret ...
- JavaScript实现自定义日期时间
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Bugku-CTF之成绩单(快来查查成绩吧)
Day18 成绩单 快来查查成绩吧http://123.206.87.240:8002/chengjidan/ 本题要点:sql手注.查询基础命令 首先查看一下源码
- 读Vue源码二 (响应式对象)
vue在init的时候会执行observer方法,如果value是对象就直接返回,如果对象上没有定义过_ob_这个属性,就 new Observer实例 export function observe ...