Spring Cloud git configuration -- placing repository in folder directly containing the classpath?
Asked Answered
E

8

10

I want to place the git repository in a folder directly above the classpath during the development stage of an application.

Currently, I have this as my Spring Cloud git URI:

spring.cloud.config.server.git.uri=file://${user.dir}/cloud-configuration-repository

This URI points to a folder directly above the classpath.

I get this error, however, during runtime.

***************************
APPLICATION FAILED TO START
***************************

Description:

Invalid config server configuration.

Action:

If you are using the git profile, you need to set a Git URI in your configuration.  If you are using a native profile and have spring.cloud.config.server.bootstrap=true, you need to use a composite configuration.

Edit: here is the project structure that I wish to have:

Project
├── _.idea
├── src
|   ├── main
|   └── test
├── target
└── cloud-configuration-repository
Embank answered 14/12, 2018 at 21:48 Comment(3)
Do you have spring.cloud.config.server.bootstrap=true?Remit
No, though I just tried it and it made no difference. I followed this guide to a T except for the Git URI: https://spring.io/guides/gs/centralized-configuration/Embank
can we see your configuration?Remit
K
12

From the documentation:

https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_server.html

2.1.3 File System Backend: There is also a “native” profile in the Config Server that does not use Git but loads the config files from the local classpath or file system (any static URL you want to point to with spring.cloud.config.server.native.searchLocations). To use the native profile, launch the Config Server with spring.profiles.active=native.

So, in your case, it would be:

spring.profiles.active=native
spring.cloud.config.server.native:searchLocations=file://${user.dir}/cloud-configuration-repository
Kamakura answered 15/12, 2018 at 0:2 Comment(2)
What if I wanted to have my config folder as a Git subrepository of my Git project? I'll put the structure as an edit in the OPEmbank
then it should be fine to use spring.cloud.config.server.git.uri with git uriKamakura
G
5

I had the exact same problem that @Nuradin was having, and the problem was that I had added the spring.cloud.config.server.git.uri property in the wrong file. I needed to add that line to the application.properties files instead of my service.properties file. Here's what my application.properties file now looks like:

spring.application.name=spring-cloud-config-server
server.port=8888
spring.cloud.config.server.git.uri: file://${user.home}/cloud-git-repo

I'm using Spring Tool Suite on Windows 10.

Gripping answered 17/5, 2019 at 13:16 Comment(1)
Yes! This is what I ended up having to do.Embank
A
4

I was getting the similar error in my application, here is the fix for the same:

a) Please add @EnableConfigServer annotation in your SpringBootApplication class

@EnableConfigServer
@SpringBootApplication
public class SpringsCloudConfigServerApplication {
--
--
}

b) Add below entries in your application.properties file

spring.profiles.active=native
spring.cloud.config.server.native:searchLocations=file://ClasspathOfYourFile

or

spring.profiles.active=native
server.cloud.config.server.git.uri=file://ClasspathOfYourFile
Adim answered 29/8, 2020 at 3:33 Comment(0)
M
4

I had the same problem, I solved it by renaming the bootstrap.yml file to application.yml.

Myrick answered 1/9, 2022 at 13:29 Comment(1)
This did it for me too, thanks.Kristine
R
0

I had a similar problem, yours decisions are work too. But I had a wish use bootstrap.yml. And this problem was solved by added dependencies as:

implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap:4.0.2'

after added it, I splitted configuration. source: Spring Boot 3.1.5 Spring Cloud

Rightism answered 18/11, 2023 at 16:51 Comment(0)
O
0

use: spring: profiles: active: native in config-server application.yaml file

Orwin answered 18/1 at 21:25 Comment(0)
M
0

Just add these entries to your application.properties file:

spring.profiles.active=native
server.cloud.config.server.git.uri=file://ClasspathOfYourFile
Meninges answered 22/2 at 21:30 Comment(0)
E
0

Since the changes keep going on i don't why but none of the above listed method has worked for me might be outdate here is something updated i have figured out.

spring:
  application:
    name: config-svc
  cloud:
    config:
      server:
        native:
          search-locations : file:///{{absolutePath}}
      label : main
  profiles:
    active: native

Service Running :)

Endothecium answered 19/8 at 10:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.