1、错误如下:
java
.lang
.IllegalStateException
: Failed to load property source from location
'classpath:/application.yml'
at org
.springframework
.boot
.context
.config
.ConfigFileApplicationListener$Loader
.load(ConfigFileApplicationListener
.java
:545)
at org
.springframework
.boot
.context
.config
.ConfigFileApplicationListener$Loader
.loadForFileExtension(ConfigFileApplicationListener
.java
:494)
at org
.springframework
.boot
.context
.config
.ConfigFileApplicationListener$Loader
.load(ConfigFileApplicationListener
.java
:464)
at org
.springframework
.boot
.context
.config
.ConfigFileApplicationListener$Loader
.lambda$null$
7(ConfigFileApplicationListener
.java
:443)
at java
.lang
.Iterable
.forEach(Iterable
.java
:75)
at org
.springframework
.boot
.context
.config
.ConfigFileApplicationListener$Loader
.lambda$load$
8(ConfigFileApplicationListener
.java
:443)
at java
.lang
.Iterable
.forEach(Iterable
.java
:75)
at org
.springframework
.boot
.context
.config
.ConfigFileApplicationListener$Loader
.load(ConfigFileApplicationListener
.java
:440)
at org
.springframework
.boot
.context
.config
.ConfigFileApplicationListener$Loader
.lambda$load$
0(ConfigFileApplicationListener
.java
:335)
at org
.springframework
.boot
.context
.config
.FilteredPropertySource
.apply(FilteredPropertySource
.java
:54)
at org
.springframework
.boot
.context
.config
.ConfigFileApplicationListener$Loader
.load(ConfigFileApplicationListener
.java
:323)
at org
.springframework
.boot
.context
.config
.ConfigFileApplicationListener
.addPropertySources(ConfigFileApplicationListener
.java
:214)
at org
.springframework
.boot
.context
.config
.ConfigFileApplicationListener
.postProcessEnvironment(ConfigFileApplicationListener
.java
:198)
at org
.springframework
.boot
.context
.config
.ConfigFileApplicationListener
.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener
.java
:188)
at org
.springframework
.boot
.context
.config
.ConfigFileApplicationListener
.onApplicationEvent(ConfigFileApplicationListener
.java
:176)
at org
.springframework
.context
.event
.SimpleApplicationEventMulticaster
.doInvokeListener(SimpleApplicationEventMulticaster
.java
:172)
at org
.springframework
.context
.event
.SimpleApplicationEventMulticaster
.invokeListener(SimpleApplicationEventMulticaster
.java
:165)
at org
.springframework
.context
.event
.SimpleApplicationEventMulticaster
.multicastEvent(SimpleApplicationEventMulticaster
.java
:139)
at org
.springframework
.context
.event
.SimpleApplicationEventMulticaster
.multicastEvent(SimpleApplicationEventMulticaster
.java
:127)
at org
.springframework
.boot
.context
.event
.EventPublishingRunListener
.environmentPrepared(EventPublishingRunListener
.java
:76)
at org
.springframework
.boot
.SpringApplicationRunListeners
.environmentPrepared(SpringApplicationRunListeners
.java
:53)
at org
.springframework
.boot
.SpringApplication
.prepareEnvironment(SpringApplication
.java
:345)
at org
.springframework
.boot
.SpringApplication
.run(SpringApplication
.java
:308)
at org
.springframework
.boot
.test
.context
.SpringBootContextLoader
.loadContext(SpringBootContextLoader
.java
:125)
at org
.springframework
.test
.context
.cache
.DefaultCacheAwareContextLoaderDelegate
.loadContextInternal(DefaultCacheAwareContextLoaderDelegate
.java
:99)
at org
.springframework
.test
.context
.cache
.DefaultCacheAwareContextLoaderDelegate
.loadContext(DefaultCacheAwareContextLoaderDelegate
.java
:124)
at org
.springframework
.test
.context
.support
.DefaultTestContext
.getApplicationContext(DefaultTestContext
.java
:123)
at org
.springframework
.test
.context
.web
.ServletTestExecutionListener
.setUpRequestContextIfNecessary(ServletTestExecutionListener
.java
:190)
at org
.springframework
.test
.context
.web
.ServletTestExecutionListener
.prepareTestInstance(ServletTestExecutionListener
.java
:132)
at org
.springframework
.test
.context
.TestContextManager
.prepareTestInstance(TestContextManager
.java
:244)
at org
.springframework
.test
.context
.junit
.jupiter
.SpringExtension
.postProcessTestInstance(SpringExtension
.java
:98)
at org
.junit
.jupiter
.engine
.descriptor
.ClassBasedTestDescriptor
.lambda$invokeTestInstancePostProcessors$
5(ClassBasedTestDescriptor
.java
:337)
at org
.junit
.jupiter
.engine
.descriptor
.ClassBasedTestDescriptor
.executeAndMaskThrowable(ClassBasedTestDescriptor
.java
:342)
at org
.junit
.jupiter
.engine
.descriptor
.ClassBasedTestDescriptor
.lambda$invokeTestInstancePostProcessors$
6(ClassBasedTestDescriptor
.java
:337)
at java
.util
.stream
.ReferencePipeline$
3$
1.accept(ReferencePipeline
.java
:193)
at java
.util
.stream
.ReferencePipeline$
2$
1.accept(ReferencePipeline
.java
:175)
at java
.util
.ArrayList$ArrayListSpliterator
.forEachRemaining(ArrayList
.java
:1382)
at java
.util
.stream
.AbstractPipeline
.copyInto(AbstractPipeline
.java
:481)
at java
.util
.stream
.AbstractPipeline
.wrapAndCopyInto(AbstractPipeline
.java
:471)
at java
.util
.stream
.StreamSpliterators$WrappingSpliterator
.forEachRemaining(StreamSpliterators
.java
:312)
at java
.util
.stream
.Streams$ConcatSpliterator
.forEachRemaining(Streams
.java
:743)
at java
.util
.stream
.Streams$ConcatSpliterator
.forEachRemaining(Streams
.java
:742)
at java
.util
.stream
.ReferencePipeline$Head
.forEach(ReferencePipeline
.java
:580)
at org
.junit
.jupiter
.engine
.descriptor
.ClassBasedTestDescriptor
.invokeTestInstancePostProcessors(ClassBasedTestDescriptor
.java
:336)
at org
.junit
.jupiter
.engine
.descriptor
.ClassBasedTestDescriptor
.instantiateAndPostProcessTestInstance(ClassBasedTestDescriptor
.java
:259)
at org
.junit
.jupiter
.engine
.descriptor
.ClassBasedTestDescriptor
.lambda$testInstancesProvider$
2(ClassBasedTestDescriptor
.java
:252)
at java
.util
.Optional
.orElseGet(Optional
.java
:267)
at org
.junit
.jupiter
.engine
.descriptor
.ClassBasedTestDescriptor
.lambda$testInstancesProvider$
3(ClassBasedTestDescriptor
.java
:251)
at org
.junit
.jupiter
.engine
.execution
.TestInstancesProvider
.getTestInstances(TestInstancesProvider
.java
:29)
at org
.junit
.jupiter
.engine
.descriptor
.TestMethodTestDescriptor
.lambda$prepare$
0(TestMethodTestDescriptor
.java
:106)
at org
.junit
.platform
.engine
.support
.hierarchical
.ThrowableCollector
.execute(ThrowableCollector
.java
:73)
at org
.junit
.jupiter
.engine
.descriptor
.TestMethodTestDescriptor
.prepare(TestMethodTestDescriptor
.java
:105)
at org
.junit
.jupiter
.engine
.descriptor
.TestMethodTestDescriptor
.prepare(TestMethodTestDescriptor
.java
:69)
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.lambda$prepare$
1(NodeTestTask
.java
:107)
at org
.junit
.platform
.engine
.support
.hierarchical
.ThrowableCollector
.execute(ThrowableCollector
.java
:73)
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.prepare(NodeTestTask
.java
:107)
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.execute(NodeTestTask
.java
:75)
at java
.util
.ArrayList
.forEach(ArrayList
.java
:1257)
at org
.junit
.platform
.engine
.support
.hierarchical
.SameThreadHierarchicalTestExecutorService
.invokeAll(SameThreadHierarchicalTestExecutorService
.java
:38)
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.lambda$executeRecursively$
5(NodeTestTask
.java
:139)
at org
.junit
.platform
.engine
.support
.hierarchical
.ThrowableCollector
.execute(ThrowableCollector
.java
:73)
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.lambda$executeRecursively$
7(NodeTestTask
.java
:125)
at org
.junit
.platform
.engine
.support
.hierarchical
.Node
.around(Node
.java
:135)
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.lambda$executeRecursively$
8(NodeTestTask
.java
:123)
at org
.junit
.platform
.engine
.support
.hierarchical
.ThrowableCollector
.execute(ThrowableCollector
.java
:73)
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.executeRecursively(NodeTestTask
.java
:122)
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.execute(NodeTestTask
.java
:80)
at java
.util
.ArrayList
.forEach(ArrayList
.java
:1257)
at org
.junit
.platform
.engine
.support
.hierarchical
.SameThreadHierarchicalTestExecutorService
.invokeAll(SameThreadHierarchicalTestExecutorService
.java
:38)
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.lambda$executeRecursively$
5(NodeTestTask
.java
:139)
at org
.junit
.platform
.engine
.support
.hierarchical
.ThrowableCollector
.execute(ThrowableCollector
.java
:73)
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.lambda$executeRecursively$
7(NodeTestTask
.java
:125)
at org
.junit
.platform
.engine
.support
.hierarchical
.Node
.around(Node
.java
:135)
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.lambda$executeRecursively$
8(NodeTestTask
.java
:123)
at org
.junit
.platform
.engine
.support
.hierarchical
.ThrowableCollector
.execute(ThrowableCollector
.java
:73)
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.executeRecursively(NodeTestTask
.java
:122)
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.execute(NodeTestTask
.java
:80)
at org
.junit
.platform
.engine
.support
.hierarchical
.SameThreadHierarchicalTestExecutorService
.submit(SameThreadHierarchicalTestExecutorService
.java
:32)
at org
.junit
.platform
.engine
.support
.hierarchical
.HierarchicalTestExecutor
.execute(HierarchicalTestExecutor
.java
:57)
at org
.junit
.platform
.engine
.support
.hierarchical
.HierarchicalTestEngine
.execute(HierarchicalTestEngine
.java
:51)
at org
.junit
.platform
.launcher
.core
.DefaultLauncher
.execute(DefaultLauncher
.java
:229)
at org
.junit
.platform
.launcher
.core
.DefaultLauncher
.lambda$execute$
6(DefaultLauncher
.java
:197)
at org
.junit
.platform
.launcher
.core
.DefaultLauncher
.withInterceptedStreams(DefaultLauncher
.java
:211)
at org
.junit
.platform
.launcher
.core
.DefaultLauncher
.execute(DefaultLauncher
.java
:191)
at org
.junit
.platform
.launcher
.core
.DefaultLauncher
.execute(DefaultLauncher
.java
:128)
at com
.intellij
.junit5
.JUnit5IdeaTestRunner
.startRunnerWithArgs(JUnit5IdeaTestRunner
.java
:74)
at com
.intellij
.rt
.execution
.junit
.IdeaTestRunner$Repeater
.startRunnerWithArgs(IdeaTestRunner
.java
:47)
at com
.intellij
.rt
.execution
.junit
.JUnitStarter
.prepareStreamsAndStart(JUnitStarter
.java
:242)
at com
.intellij
.rt
.execution
.junit
.JUnitStarter
.main(JUnitStarter
.java
:70)
Caused by
: org
.yaml
.snakeyaml
.scanner
.ScannerException
: while scanning
for the next token
found character
'%' that cannot start any token
. (Do not use
% for indentation
)
in
'reader', line
16, column
12:
console
: %d
{yyyy
-MM
-dd HH
:mm
:ss
.SSS
} === ...
2、lz的错误是配置日志的时候%没有转义,在配置日志输出格式时候加双引号即可,如下图:
3、启动成功如下图: