Hello everyone I'm facing issue with running heroku server locally I believe there's more then one error but I don't know what is the main issue. I have add procfile and the database configuration as provided bellow 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:
plugins {
id 'org.springframework.boot' version '2.6.1'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'com.discount'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation group: 'javax.persistence', name: 'javax.persistence-api', version: '2.2'
implementation group: 'org.springframework.boot', name: 'spring-boot-starter-jdbc', version: '2.6.0'
implementation group: 'org.postgresql', name: 'postgresql', version: '42.3.1'
}
test {
useJUnitPlatform()
}
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);
}
}