Error creating bean with name dataSourceScriptDatabaseInitializer defined in class path resource
Questions : Error creating bean with name dataSourceScriptDatabaseInitializer defined in class path resource
2022-09-16T05:05:26+00:00 2022-09-16T05:05:26+00:00
419
Hello everyone I'm facing issue with running anycodings_heroku-postgres heroku server locally I believe there's anycodings_heroku-postgres more then one error but I don't know what is anycodings_heroku-postgres the main issue. I have add procfile and the anycodings_heroku-postgres database configuration as provided bellow anycodings_heroku-postgres in the code.
6:43:37 PM web.1 | ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ 6:43:37 PM web.1 | \\/ ___)| |_)| | | | | || (_| | ) ) ) ) 6:43:37 PM web.1 | ' |____| .__|_| |_|_| |_\__, | / / / / 6:43:37 PM web.1 | :: Spring Boot :: (v2.6.1) 6:43:37 PM web.1 | 2021-12-14 18:43:37.764 INFO 269 --- [ main] c.discount.discount.DiscountApplication : Starting DiscountApplication using Java 11.0.11 on Sabbagh99 with PID 269 (/mnt/c/Users/ad199/IdeaProjects/Discounts-Web-Api-old/build/libs/discount-0.0.1-SNAPSHOT.jar started by sabbagh99 in /mnt/c/Users/ad199/IdeaProjects/Discounts-Web-Api-old) 6:43:37 PM web.1 | 2021-12-14 18:43:37.777 INFO 269 --- [ main] c.discount.discount.DiscountApplication : No active profile set, falling back to default profiles: default 6:43:39 PM web.1 | 2021-12-14 18:43:39.864 INFO 269 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode. 6:43:40 PM web.1 | 2021-12-14 18:43:40.022 INFO 269 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 123 ms. Found 1 JPA repository interfaces. 6:43:41 PM web.1 | 2021-12-14 18:43:41.697 INFO 269 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 6:43:41 PM web.1 | 2021-12-14 18:43:41.727 INFO 269 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 6:43:41 PM web.1 | 2021-12-14 18:43:41.727 INFO 269 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.55] 6:43:41 PM web.1 | 2021-12-14 18:43:41.981 INFO 269 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 6:43:41 PM web.1 | 2021-12-14 18:43:41.981 INFO 269 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 3820 ms 6:43:42 PM web.1 | 2021-12-14 18:43:42.202 WARN 269 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSource 6:43:42 PM web.1 | > ScriptDatabaseInitializer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'databaseConfig': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.datasource.url' in value "${spring.datasource.url}" 6:43:42 PM web.1 | 2021-12-14 18:43:42.210 INFO 269 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 6:43:42 PM web.1 | 2021-12-14 18:43:42.262 INFO 269 --- [ main] ConditionEvaluationReportLoggingListener : 6:43:42 PM web.1 | Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 6:43:42 PM web.1 | 2021-12-14 18:43:42.346 ERROR 269 --- [ main] o.s.boot.SpringApplication : Application run failed 6:43:42 PM web.1 | org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'databaseConfig': Injection of aut 6:43:42 PM web.1 | > owired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.datasource.url' in value "${spring.datasource.url}" 6:43:42 PM web.1 | at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290) ~[spring-boot-2.6.1.jar!/:2.6.1] 6:43:42 PM web.1 | at com.discount.discount.DiscountApplication.main(DiscountApplication.java:10) ~[classes!/:na] 6:43:42 PM web.1 | at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[discount-0.0.1-SNAPSHOT.jar:na] 6:43:42 PM web.1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:108) ~[discount-0.0.1-SNAPSHOT.jar:na] 6:43:42 PM web.1 | at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[discount-0.0.1-SNAPSHOT.jar:na] 6:43:42 PM web.1 | at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) ~[discount-0.0.1-SNAPSHOT.jar:na] 6:43:42 PM web.1 | Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'databaseConfig': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.datasource.url' in value "${spring.datasource.url}" 6:43:42 PM web.1 | at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:405) ~[spring-beans-5.3.13.jar!/:5.3.13] 6:43:42 PM web.1 | at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431) ~[spring-beans-5.3.13.jar!/:5.3.13] 6:43:42 PM web.1 | Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.datasource.url' in value "${spring.datasource.url}" 6:43:42 PM web.1 | at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:180) ~[spring-core-5.3.13.jar!/:5.3.13]** and here's my files : **
Gradle:
data base configuration class :
@Value("${spring.datasource.url}") private String dbUrl; @Bean public DataSource dataSource() { HikariConfig config = new HikariConfig(); config.setJdbcUrl(dbUrl); return new HikariDataSource(config); } }Total Answers 1
33
Answers 1 : of Error creating bean with name dataSourceScriptDatabaseInitializer defined in class path resource
The exception is telling you that the anycodings_spring bean can't be created because you anycodings_spring haven't defined the property anycodings_spring spring.datasource.url.
If you're using a yml configuration, anycodings_spring (for example in src/main/resources you anycodings_spring have the file application.yml), open it anycodings_spring and add the datasource property under anycodings_spring "spring":
spring: datasource: url: # db connection url hereIf you're using a properties file the anycodings_spring format changes to
spring.datasource.url= # db connection url here0
2022-09-16T05:05:26+00:00 2022-09-16T05:05:26+00:00Answer Link
mRahman