-
2021-06-15 05:13:05
spring.datasource.name 和spring.datasource.username
所踩的坑
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/thread?useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.datasource.username=root
spring.datasource.password=ying.115以上的是正确的用法
而这个却不知道有什么当你用idea的时候。用提示里给的选择会有这个。
我也看过源码却实不知里面的作用。这个让我也很头痛。也让我踩了一个大坑所以我记录一下
spring.datasource.name=更多相关内容 -
报错解决:Could not resolve placeholder ‘spring.datasource.url‘ in value “${spring.datasource.url...
2021-11-16 22:22:45原因 由于 Git 的分支切换问题,导致需要重新导入 JDK ,而且, IDEA 没有自动识别当前项目为 Maven 管理的项目,所以需要重新导入一下。 解决办法 看一下自己是不是 Maven 项目,点击 IDEA 下图中的1,然后看一下3... -
Could not resolve placeholder 'spring.datasource.url' in value "${spring.datasource.url}
2019-05-07 14:37:22参考:http://120.203.18.89:6969/41/could-not-resolve-placeholder-spring-datasource-url-in-value-spring-datasource-url/ 今天在测试环境运行Maven工程时,出现莫名其妙的无法初始化mybatis错误,主要是读取不...今天在测试环境运行Maven工程时,出现莫名其妙的无法初始化mybatis错误,主要是读取不到配置文件里面,关于数据库的配置。
工程有多个profile,在Idea里面设置了运行时的配置文件,但是运行时没有生效。
最后通过修改Maven解决,不用自带的Maven。
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'mybatisConfig': Unsatisfied dependency expressed through field 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'druidConfig': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.datasource.url' in value "${spring.datasource.url}" at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:587) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:373) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1344) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:578) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1325) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1291) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1193) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1096) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:659) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] ... 45 common frames omitted Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'druidConfig': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.datasource.url' in value "${spring.datasource.url}" at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:379) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1344) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:578) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:368) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1250) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:541) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:584) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] ... 61 common frames omitted Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.datasource.url' in value "${spring.datasource.url}" at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:172) ~[spring-core-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124) ~[spring-core-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:237) ~[spring-core-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:211) ~[spring-core-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.lambda$processProperties$0(PropertySourcesPlaceholderConfigurer.java:175) ~[spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue(AbstractBeanFactory.java:839) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1086) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:584) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:373) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE] ... 81 common frames omitted
-
spring.datasource.url与spring.datasource.jdbc-url
2018-05-11 16:35:39今天使用spring boot配置两个数据源,出现了...app.datasource.url=jdbc:mysql://localhost/test app.datasource.username=dbuser app.datasource.password=dbpass app.datasource.driverClassName=com.mysql.cj.jdb...今天使用spring boot配置两个数据源,出现了问题。
使用数据源配置
app.dataource.url=jdbc:mysql://localhost/test app.datasource.username=dbuser app.datasource.password=dbpass app.datasource.driverClassName=com.mysql.cj.jdbc.Driver
提示我:jdbcUrl is required with driverClassName。上网搜了一下,结果是使用app.datasource.url的锅。
spring.datasource.url 数据库的 JDBC URL。
spring.datasource.jdbc-url 用来创建连接的 JDBC URL。
官方文档的解释是:
因为连接池的实际类型没有被公开,所以在您的自定义数据源的元数据中没有生成密钥,而且在IDE中没有完成(因为DataSource接口没有暴露属性)。另外,如果您碰巧在类路径上有Hikari,那么这个基本设置就不起作用了,因为Hikari没有url属性(但是确实有一个jdbcUrl属性)。在这种情况下,您必须重写您的配置如下:
app.datasource.jdbc-url=jdbc:mysql://localhost/test app.datasource.username=dbuser app.datasource.password=dbpass
-
项目启动报错:Could not resolve placeholder 'spring.datasource.url' in value "${spring.datasource....
2020-03-26 13:14:551.要确保你的配置的文件字符格式无误,确保文件存在 2.项目在配置更改后要对maven进行clean,install的操作,清除以重新编译项目 选择项目 Run As -
spring.datasource.url:本地连接URL简写
2020-08-07 16:28:11spring: datasource: url: jdbc:mysql:///database-name username: root password: root -
Failed to auto-configure a DataSource: ‘spring.datasource.url‘ is not specified and no embedded ...
2022-03-21 18:54:06Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-configured. Reason: Failed to determine a suitable driver class Action: ... -
启动错误:Could not resolve placeholder 'spring.datasource.url' in value "${spring.datasource.url}
2018-03-19 13:47:16项目启动报错:Could not resolve placeholder 'spring.datasource.url' in value "${spring.datasource.url}"项目在配置更改后要对maven进行clean,install的操作,清除以重新编译项目... -
解析mysql的spring.datasource.url获取host,端口,数据库名,获取表里的 字段名,字段类型,字段注释
2020-12-16 09:48:00解析mysql的spring.datasource.url获取host,端口,数据库名,获取表里的 字段名,字段类型,字段注释 做项目做了一个功能:需要展示一个表中的所有信息:字段名,字段类型,字段注释。 需要解析mysql的url,获取到... -
java.lang.IllegalStateException: Cannot decrypt: key=spring.datasource.password
2020-04-25 12:28:36Spring Cloud Config Server服务启动报错,如下所示: 2020-04-25 10:10:22.089 INFO 4028 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.... -
Cannot resolve configuration property ‘spring.datasource.timeBetweenEvictionRunsMillis
2021-12-21 12:21:48spring: profiles: active: dev datasource: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://127.0.0.1:4406/demo?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=... -
springboot配置mysql数据库spring.datasource.url报错处理
2018-10-24 17:19:30spring.datasource.url=jdbc:mysql://abc:3306/abcd?useUnicode=true&characterEncoding=utf8 很常规地配置了这个mysql的url后发现报错 Wed Oct 24 14:59:16 CST 2018 WARN: Establishing SSL connection ... -
spring.datasource.schema配置
2019-05-22 11:42:12用springboot2.0执行sql脚本: 1.现将sql文件放在resources下的sql文件夹下 ...spring: datasource: # 数据源基本配置 username: root password: 123 driver-class-name: com.mysql.cj.jdbc.Driver ... -
关于使用spring.datasource.hikari连接数据库找不到找不到url的问题
2019-09-08 18:35:46关于使用spring.datasource.hikari连接数据库找不到找不到url的问题applica.properties里配置连接数据库使用hikari出现的问题异常解决 配置重定义识别数据库连接方式为spring.datasource.primary完美解决 ... -
spring boot服务器启动报错'spring.datasource.url' is not specified
2018-04-27 11:00:39报错信息'spring.datasource.url' is not specified and no embedded datasource could be auto-configured.原因数据库没有配置,在启动的文件的注解@SpringBootApplication中加入参数@SpringBootApplication... -
Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded data
2019-08-29 11:16:04这个错误的大致意思就是说,未能自动配置数据源:未指定“spring.datasource.url”,并且无法自动配置嵌入的数据源。 如果当前项目中不需要使用数据源,且触发了数据源配置则会报这样的错误。其原因是提供API的依赖... -
configure a DataSource: 'spring.datasource.url'
2018-08-10 16:51:10Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified and no embedded datasource could be auto-configured. 今天解决了一个springboot jpa的通用数据库配置BUG,记录一下,... -
解决spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver出错
2021-03-20 18:32:19##解决spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver出错 ###idea project->右键->open module setting->libraries->+号->导入本地的mysql包即可 在此感谢... -
Failed to bind properties under 'spring.datasource' to javax.sql.DataSource:
2019-09-06 15:38:35springboot整合druid时,引入了druid的数据源,在配置文件application.yml中...spring: datasource: username: root password: 123456 url: jdbc:mysql://192.168.2.218:3306/test driver-class-name: com.mysq... -
Failed to bind properties under ‘spring.datasource.password‘ to java.lang.String: Reason: Failed ...
2021-10-02 17:24:11Failed to bind properties under 'spring.datasource.password' to java.lang.String: Reason: Failed to bind properties under 'spring.datasource.password' to java.lang.String Action: Update your ... -
SpringBoot启动报错:Failed to auto-configure a DataSource: 'spring.datasource.url' is not specified ...
2018-08-16 00:19:16今天倒腾了一下自己的SpringBoot demo的代码,发现启动报了如下的错误: *************************** APPLICATION FAILED TO START ...Failed to auto-configure a DataSource: 'spring.datas... -
Failed to bind properties under ‘spring.datasource.password‘ to java.lang.String: Reason: Fail
2020-09-08 11:25:02Failed to bind properties under 'spring.datasource.password' to java.lang.String: Reason: Failed to bind properties under 'spring.datasource.password' to java.lang.String Action: Update your ... -
Springboot(二十)启动时数据库初始化spring.datasource/spring.jpa
2018-08-26 16:03:221.使用springboot jdbc初始化数据库 ...spring: datasource: username: xuhaixing password: xuhaixing url: jdbc:mysql://192.168.94.151:3306/mytest?useUnicode=true&characterEncoding=utf8&charac... -
Springboot启动报错:Failed to bind properties under spring.datasource to javax.sql.DataSource
2018-09-20 10:02:13项目结构: DruidConfig: package ... ...import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.druid.support.http.StatViewServlet; import com.alibaba.druid.support.... -
Could not resolve placeholder ‘spring.datasource.driver-class-name‘ in value
2021-04-12 10:33:20url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai driver-class-name: com.mysql.cj.jdbc.Driver username: root passwo -
【springboot学习笔记二】spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver报错
2020-09-24 17:04:35如何解决spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver无法引用,如下: 解决方案,在pom.xml找到自动创建项目时导入的mysql .jar包 <!-- mysql--> <dependency> <groupId&... -
Error processing condition on com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataS
2020-09-21 17:19:51Error processing condition on com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration.dynamicDataSourceCreator 解决办法: 引入这两个包 在这里插入代码片 <... -
springboot2.x整合druid 不能识别spring.datasource.type 的值
2019-08-10 19:11:24springboot2.x整合druid数据源时,在配置文件中配置spring.datasource.type 属性时,不能识别 com.alibaba.druid.pool.DruidDataSource,并且启动报错 错误: rror starting ApplicationContext. To display ...