I have the maven spring microservice with main class.
@EnableEncryptableProperties
@SpringBootApplication
@EnableDiscoveryClient
public class AccountService {
private static ApplicationContext applicationContext;
public static void main(String[] args) {
applicationContext = SpringApplication.run(AccountService.class, args);
}
}
In my pom.xml I added following dependencies for registering app.
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
<version>2.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
<version>1.3.5.RELEASE</version>
</dependency>
During startup I get the following error.
[WARN ] 2021-01-11 22:05:50 [main] AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.microservices.accountservice.AccountService]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class] cannot be opened because it does not exist
[ERROR] 2021-01-11 22:05:50 [main] SpringApplication - Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.microservices.accountservice.AccountService]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/boot/autoconfigure/web/ServerPropertiesAutoConfiguration.class] cannot be opened because it does not exist
The project has defined the following spring version.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
Moreover microservice during startup communicates using bootstrap.properties with spring-cloud-config-server to fetch application.properties. What could be the issue related with this error ?
The dependencies in your pom.xml
are not compatible with each other. You should use spring-cloud-starter-netflix-eureka-client:2.2.6.RELEASE
.
It is even better if you don't specify the versions for each of your dependencies but you use the BOM (spring-cloud-dependencies
), see the official guide.