Caused by: org.yaml.snakeyaml.scanner.ScannerException
程序员文章站
2022-04-15 17:35:37
...
SPRING APPLICATION使用@ 使用的问题:'@' THAT CANNOT START ANY TOKEN. (DO NOT USE @ FOR INDENTATION)
标签: Spring spring boot spring maven
错误信息
在application配置文件中使用@出现异常:
Exception in thread "main" while scanning for the next token
found character '@' that cannot start any token. (Do not use @ for indentation)
in 'reader', line 4, column 11:
name: @[email protected]
代码:
info:
app:
name: @[email protected]
encoding: @[email protected]
java:
source: @[email protected]
target: @[email protected]
解决办法
- 用单引号或双引号将@@之间的内容包起来
info:
app:
name: "@[email protected]"
encoding: '@[email protected]'
java:
source: '@[email protected]'
target: '@[email protected]'
- 或者添加maven依赖
使用Maven的资源过滤(resource filter)自动暴露来自Maven项目的属性,如果使用spring-boot-starter-parent,你可以通过@…@占位符引用Maven项目的属性,例如:
[email protected]@
[email protected]@
注 如果启用addResources标识,spring-boot:run可以将src/main/resources直接添加到classpath(出于热加载目的),这就绕过了资源过滤和本特性。你可以使用exec:java目标进行替代,或自定义该插件的配置,具体查看插件使用页面
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<configuration>
<delimiters>
<delimiter>@</delimiter>
</delimiters>
<useDefaultDelimiters>false</useDefaultDelimiters>
</configuration>
</plugin>
<plugins/>
注 如果你在配置中使用标准的Spring占位符(比如${foo})且没有将useDefaultDelimiters属性设置为false,那构建时这些属性将被暴露出去
上一篇: Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning a simple key
下一篇: org.yaml.snakeyaml.scanner.ScannerException: while scanning an alias in ‘reader‘, line 42, column 1
推荐阅读
-
Android Caused by: java.lang.ClassNotFoundException解决办法
-
Android Caused by: java.lang.ClassNotFoundException解决办法
-
Caused by SSLError("Can’t connect to HTTPS URL because the SSL module is not available)
-
Caused by: android.os.NetworkOnMainThreadException错误解决办法
-
Caused by: java.lang.reflect.InvocationTargetException
-
安装ssl证书后报错Caused by: java.io.IOException: DerInputStream.getLength(): lengthTag=109, too big.
-
Caused by: com.rabbitmq.client.AuthenticationFailureException: ACCESS_REFUSED - Login was refused using authentication mechanism PLAIN. For details se
-
Caused by: java.lang.ClassNotFoundException: org.junit.platform.launcher.TestExecutionListener
-
idea启动项目报错Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
-
Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value '�й���ʱ��' is unrecognized or represents m