I have sample Spring Boot application, with Gradle I was able to compile it. but while running its giving the below error message.
java.io.FileNotFoundException: class path resource [org/springframework/boot/autoconfigure/data/jpa/EntityManagerFactoryDependsOnPostProcessor.class] cannot be opened because it does not exist
2022-07-07 21:56:29.747 DEBUG 20120 --- [restartedMain] com.usbank.appfit.Application : Running with Spring Boot v2.7.0, Spring v5.3.20
2022-07-07 21:56:29.747 INFO 20120 --- [restartedMain] com.usbank.appfit.Application : No active profile set, falling back to 1 default profile: "default"
2022-07-07 21:56:29.821 INFO 20120 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2022-07-07 21:56:29.822 INFO 20120 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2022-07-07 21:56:30.898 WARN 20120 --- [restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [org.springframework.boot.devtools.autoconfigure.DevToolsDataSourceAutoConfiguration]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/boot/autoconfigure/data/jpa/EntityManagerFactoryDependsOnPostProcessor.class] cannot be opened because it does not exist
2022-07-07 21:56:30.918 INFO 20120 --- [restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-07-07 21:56:30.986 ERROR 20120 --- [restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [org.springframework.boot.devtools.autoconfigure.DevToolsDataSourceAutoConfiguration]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/boot/autoconfigure/data/jpa/EntityManagerFactoryDependsOnPostProcessor.class] cannot be opened because it does not exist
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:610)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:311)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:250)
at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:600)
at org.springframework.context.annotation.ConfigurationClassParser.access$800(ConfigurationClassParser.java:111)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.lambda$processGroupImports$1(ConfigurationClassParser.java:812)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGroupingHandler.processGroupImports(ConfigurationClassParser.java:809)
at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorHandler.process(ConfigurationClassParser.java:780)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:193)
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/boot/autoconfigure/data/jpa/EntityManagerFactoryDependsOnPostProcessor.class] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:199)
Using below build.gradle
file.
plugins {
id 'org.springframework.boot'
id 'io.spring.dependency-management'
id 'java'
id 'maven-publish'
id 'war'
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter:2.3.10.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-web:2.3.10.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-actuator:2.3.10.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.3.10.RELEASE'
implementation 'com.h2database:h2:1.4.200'
implementation 'org.springframework.boot:spring-boot-devtools:2.3.10.RELEASE'
testImplementation 'org.apache.httpcomponents:httpclient:4.5.7'
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.3.10.RELEASE'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.0'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.4.0'
}
May I know which dependencies need to be included to resolve this error?
Thanks
CodePudding user response:
If you use the org.springframework.boot
gradle plugin you don't need to specify most of the versions of the dependencies used by Spring Boot since the plugin manages them for you:
dependencies {
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'com.h2database:h2'
implementation 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.apache.httpcomponents:httpclient'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.junit.jupiter:junit-jupiter-api'
testImplementation 'org.junit.jupiter:junit-jupiter-engine'
}
The versions of those dependencies will be set according to the org.springframework.boot
plugin version used which in your case is 2.7.0:
Running with Spring Boot v2.7.0, Spring v5.3.20
The plugin version is generally specified like this:
plugins {
id 'org.springframework.boot' version '2.7.0'
}
See https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/htmlsingle/ for more info.