I have migrated my project from gradle 5 to 7.1 and spring boot 2.5.3. After i build the jar, i tried to execute the same. Earlier it was working fine. But now, its not detecting the application.properties file. I have tried many solutions in Stackoverflow and other website, but it didn't help me. It would be very helpful if anyone can point out my mistake. Am trying to execute in windows machine. application.properties file is present inside config folder which is parallel to jar
Attempt 1:
java -Dloader.path=.,config\ -jar xyz-1.0.0.jar
error :
class path resource [application.properties] cannot be opened because it does not exist
Attempt 2:
java -Dspring.config.location=classpath:/application.properties -jar xyz-1.0.0.jar
error :
ConfigDataResourceNotFoundException: Config data resource 'class path resource [application.properties]' via location 'classpath:/application.properties' cannot be found
Attempt 3:
java -jar xyz-1.0.0.jar -Dspring.config.location=classpath:/application.properties
error :
FileNotFoundException: class path resource [application.properties] cannot be opened because it does not exist
Attempt 4:
java -Dspring.config.location=file:c:\Sheljith\tools\config\application.properties -jar xyz-1.0.0.jar
error :
FileNotFoundException: class path resource [application.properties] cannot be opened because it does not exist
Attempt 5:
java --spring.config.location=file:c:\Sheljith\tools\config\application.properties -jar xyz-1.0.0.jar
error :
Unrecognized option: --spring.config.location=file:c:\Sheljith\tools\config\application.properties
Attempt 6:
java -Dspring.config.name=application -Dspring.config.location=file:///C:/Sheljith/tools/drc-reports-generator/config/ -jar xyz-1.0.0.jar
error:
.FileNotFoundException: class path resource [application.properties] cannot be opened because it does not exist
Attempt 7:
java -Dspring.config.location=file:///C:/Sheljith/tools/config/application.properties -jar xyz-1.0.0.jar
error:
class path resource [application.properties] cannot be opened because it does not exist
build.gradle
buildscript {
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin")
}
}
plugins {
id 'org.springframework.boot' version '2.5.3'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
jar.archiveName = "drc-reports-generator.jar"
version = '1.0.0'
sourceCompatibility = '1.8'
jar {
manifest {
attributes 'Implementation-Title': 'Gradle Quickstart',
'Implementation-Version': version
}
}
repositories {
mavenCentral()
mavenLocal()
}
processResources{
exclude '*/**'
}
springBoot{
mainClass = "com.xyz.Application"
}
dependencies {
implementation group: 'commons-collections', name: 'commons-collections', version: '3.2'
implementation("org.springframework.boot:spring-boot-starter")
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
testImplementation("org.springframework.boot:spring-boot-starter-test")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
testImplementation group: 'junit', name: 'junit', version: '4.+'
testImplementation group: 'com.tngtech.java', name: 'junit-dataprovider', version: '1.13.1'
implementation 'com.itextpdf:itextpdf:5.5.11'
implementation 'org.springframework:spring-web:4.3.6.RELEASE'
implementation 'com.microsoft.sqlserver:sqljdbc4:4.0'
implementation("com.h2database:h2")
implementation("org.apache.commons:commons-lang3:3.0")
implementation group: 'com.github.ulisesbocchio', name: 'jasypt-spring-boot-starter', version: '3.0.0'
}
test {
useJUnitPlatform()
}