Caused by: java.lang.IllegalStateException: duplicate key: datasource

java.lang.IllegalStateException: Failed to load property source from location ‘classpath:/application.yaml‘
    at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:537)
    at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadForFileExtension(ConfigFileApplicationListener.java:496)
    at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:464)
    at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.lambda$null$6(ConfigFileApplicationListener.java:446)
    at java.lang.Iterable.forEach(Iterable.java:75)
    at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.lambda$load$7(ConfigFileApplicationListener.java:445)
    at java.lang.Iterable.forEach(Iterable.java:75)
    at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:442)
    at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:330)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.addPropertySources(ConfigFileApplicationListener.java:212)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.postProcessEnvironment(ConfigFileApplicationListener.java:195)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:182)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:168)
    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:74)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:358)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:317)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243)
    at com.qingmu.MySpringBootSstart.main(MySpringBootSstart.java:16)
Caused by: java.lang.IllegalStateException: duplicate key: datasource
    at org.yaml.snakeyaml.constructor.SafeConstructor.processDuplicateKeys(SafeConstructor.java:99)
    at org.yaml.snakeyaml.constructor.SafeConstructor.flattenMapping(SafeConstructor.java:70)
    at org.yaml.snakeyaml.constructor.SafeConstructor.constructMapping2ndStep(SafeConstructor.java:182)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping(BaseConstructor.java:443)
    at org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlMap.construct(SafeConstructor.java:519)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:207)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:196)
    at org.springframework.boot.env.OriginTrackedYamlLoader$OriginTrackingConstructor.constructObject(OriginTrackedYamlLoader.java:94)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping2ndStep(BaseConstructor.java:462)
    at org.yaml.snakeyaml.constructor.SafeConstructor.constructMapping2ndStep(SafeConstructor.java:183)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructMapping(BaseConstructor.java:443)
    at org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlMap.construct(SafeConstructor.java:519)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructObjectNoCheck(BaseConstructor.java:207)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructObject(BaseConstructor.java:196)
    at org.springframework.boot.env.OriginTrackedYamlLoader$OriginTrackingConstructor.constructObject(OriginTrackedYamlLoader.java:94)
    at org.yaml.snakeyaml.constructor.BaseConstructor.constructDocument(BaseConstructor.java:161)
    at org.yaml.snakeyaml.constructor.BaseConstructor.getData(BaseConstructor.java:127)
    at org.yaml.snakeyaml.Yaml$1.next(Yaml.java:547)
    at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:168)
    at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:141)
    at org.springframework.boot.env.OriginTrackedYamlLoader.load(OriginTrackedYamlLoader.java:75)
    at org.springframework.boot.env.YamlPropertySourceLoader.load(YamlPropertySourceLoader.java:50)
    at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadDocuments(ConfigFileApplicationListener.java:547)
    at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.load(ConfigFileApplicationListener.java:517)
    ... 23 common frames omitted

因为我在使用的是yaml文件模式,然后因为:

去掉三个相同的键以后,就能够正常运行了.

原文地址:https://www.cnblogs.com/qingmuchuanqi48/p/10886533.html

时间: 2024-08-27 05:36:55

Caused by: java.lang.IllegalStateException: duplicate key: datasource的相关文章

分布式配置中心config-client配置报错:java.lang.IllegalStateException: duplicate key: spring

今天练习分布式配置中心,写config-client配置文件,使用bootstrap.properties配置,运行没有问题. bootstrap.properties: spring.application.name=config-client spring.cloud.config.label=master spring.cloud.config.profile=dev spring.cloud.config.uri= http://localhost:8888/ server.port=8

JDK8 stream toMap() java.lang.IllegalStateException: Duplicate key异常解决(key重复)

测试又报bug啦 接到测试小伙伴的问题,说是一个接口不返回数据了,好吧,虽然不是我写的接口任务落到头上也得解决,本地调试了一下,好家伙,直接抛了个异常出来,这又是哪位大哥喝醉了写的代码... Exception in thread "main" java.lang.IllegalStateException: Duplicate key at java.util.stream.Collectors.lambda$throwingMerger$0(Collectors.java:133)

ssm项目——异常:Caused by: java.lang.IllegalStateException

异常:Caused by: java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'javax.sql.DataSource' for property 'dataSource': no matching editors or conversion strategy found 大意:java.lang.String 与所需要的javax.sql.Data

Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.mchange.v2.c3p0.ComboPooledDataSource] from ClassLoader [ParallelWebappClassLoader

Caused by: java.lang.IllegalStateException: Failed to introspect Class [com.mchange.v2.c3p0.ComboPooledDataSource] from ClassLoader [ParallelWebappClassLoader 020-04-11 18:49:17,914 WARN [org.springframework.web.context.support.XmlWebApplicationConte

Caused by: java.lang.IllegalStateException: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError

SLF4J: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError. SLF4J: See also http://www.slf4j.org/codes.html#log4jDelegationLoop for more details.Exception in thread "main" java.lang.Exception

Caused by: java.lang.IllegalStateException: getOutputStream() has already been called for this respo

1.错误描述 Caused by: java.lang.IllegalStateException: getOutputStream() has already been called for this response at org.apache.catalina.connector.Response.getWriter(Response.java:648) at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFa

Caused by: java.lang.IllegalStateException: The specified child already has a parent. You

ViewPager 报错:Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. 一中是removeView这个问题很常见的,具体解决方法就不谈了,另外一种是情况如下: adapter=new ViewPagerAdapter(Views); views>>  view

Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 3939

在使用Gson解析JSON数据时,报错:Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 3939 原因:传入的参数有问题: while((len=inputStream.read(data))!=-1){ outPutStream.write(data,0,len); } 错写成: while((len=inputStream.read())!=-1

dubbo应用既当提供者又当消费者java.lang.IllegalStateException: Duplicate application configs

一个dubbo的应用启动时报错:java.lang.IllegalStateException: Duplicate application configs.原因如下: 当一个应用既当提供者和消费者时,必定会分别配置应用的名称: 提供者: [html] <dubbo:application name="XXXX" /> 消费者: [html] <bean id="dubbo_application" class="com.alibaba.