Following is the pom.xml
file of my Spring Cloud Server:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.org</groupId>
<artifactId>config</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>config</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
<spring-cloud.version>2022.0.1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
This server uses a remote git repository with SSH Authentication. The application.yml
file is as follows:
server:
port: 8080
spring:
profiles:
active: composite
application:
name: config-server
cloud:
config:
server:
# https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_server.html#composite-environment-repositories
composite:
- type: git
uri: file://${user.home}/local-config-repo
defaultLabel: master
search-paths:
- roomie*
- type: git
# https://docs.spring.io/spring-cloud-config/docs/current/reference/html/#_git_backend
uri: git@github.com:Org-Engineering/config-repo.git
# https://docs.spring.io/spring-cloud-config/docs/current/reference/html/#_push_notifications_and_spring_cloud_bus
clone-on-start: true
strictHostKeyChecking: false
# https://docs.spring.io/spring-cloud-config/docs/current/reference/html/#_git_refresh_rate
refreshRate: 15
# https://docs.spring.io/spring-cloud-config/docs/current/reference/html/#_default_label
defaultLabel: master
search-paths:
- roomie*
security:
provider:
N=org.bouncycastle.jce.provider.BouncyCastleProvider:
I'm using IntelliJ Idea as my IDE and when I try to run the application from the IDE the server works. On the other hand, when I do mvn clean install
and execute the .jar
using java -jar ...
I get the following error:
org.eclipse.jgit.api.errors.TransportException: git@github.com:Org-Engineering/config-repo.git: DefaultAuthFuture[ssh-connection]: Failed (NoSuchProviderException) to execute: JCE cannot authenticate the provider BC
To try and overcome this error I added security.provider.N
property in my application.yml
file and also added a static block with Security.addProvider(new BouncyCastleProvider());
in the main class. Nothing seems to work at this point.
Why am I able to run the application using the IDE and how can I make it work with the .jar
. Any help or suggestion will be appreciated. Thanks in advance.
The problem was with the Java distribution I was using. It was fixed when I downloaded and replaced my JDK with OpenJDK distribution.