question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Consider if content assist can be offered for spring.config.import property keys

See original GitHub issue

Spring Boot 2.4 will ship with support that allows you to easily import additional config files. There’s a bit of background about the feature in this blog post. Currently the content-assist for spring.config.import will be limited to the hints that we provide in the meta-data JSON file, but we might be able to go further.

The spring.config.import key accepts a list of string location values. Locations are ultimately resolved to provide additional config data. The resolver logic is completely pluggable, but by convention a location prefix will be used to determine how the location is resolved.

Out of the box, we’ll have support for configtree: and resource:. The resource: prefix will also be used as the default of no other resolver supports the string.

Some examples:

spring.config.import=/etc/config/myfile.yml # import a file from the filesystem
#---
spring.config.import=resource:/etc/config/myfile.yml # more explicit version of above
#---
spring.config.import=classpath:extra.properties # import a classpath resource
#---
spring.config.import=resource:classpath:extra.properties # more explicit version of above
#---
spring.config.import=configtree:/etc/config/folder # import a config tree

It might be possible to offer some content-assist that would allow users to select files from either their workspace, or from their local disk. I suspect the workspace would be more useful.

For example:

The user types

spring.config.import=

Content assist could provide the usual hints:

+------------+
| classpath: |
| configtree:|
| file:      |
+------------+

It could also provide a richer “select classpath resource…” option. This could bring up a dialog similar to “Open Resource”. You could also have a “select filesystem resource…” option.

Another useful feature would be ctrl-click on a location.

For example, given:

spring.config.import=classpath:my.properties

A ctrl-click on classpath:my.properties could open the my.properties file.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
martinlippertcommented, Aug 22, 2022

I am closing this issue here as we implemented support for the classpath: prefix. We should create new and separate issues for additional improvements.

1reaction
kdvoldercommented, Jan 28, 2022

We have implemented some basic support for ‘classpath:’ prefix. Whenever we see a prefix like ‘classpath:…’ we’ll make completions based on the contents of the project’s resource source folder.

I thought about other cases and thought this is probably the only case for which the IDE has enough context information to provide meaningful completions. (I.e. we know what stuff is on the classpath but we don’t really know what is on the ‘file:’ system or the ‘config:’ tree because I would assume that this actually depends on where the program eventually gets run (e.g. inside k8s / docker container). We might consider implementing some kind of support for ‘file’ though if that seems useful (opinions welcome, either as comment in this ticket or by raising other tickets with suggestions).

For now I’ll just consider this item as complete with just support for ‘classpath:’.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No spring.config.import property has been defined
Solution for Maven. Add the below dependency in the pom.xml file: <dependency> <groupId>org.springframework.cloud</groupId> ...
Read more >
Spring Cloud Config Server
If you use Spring Cloud Config Client, you need to set the spring.config.import property in order to bind to Config Server. You can...
Read more >
Configuring region - Spring Cloud AWS
The Spring Cloud AWS configuration is currently done using custom elements provided by Spring Cloud AWS namespaces. JavaConfig will be supported soon.
Read more >
Quick Intro to Spring Cloud Configuration - Baeldung
To complete our server, we have to initialize a Git repository under the configured url, create some new properties files, and populate them...
Read more >
Centralized Configuration with Spring Cloud Config Server
If you prefer to use Apache Maven rather than Gradle, feel free to do so. On GitHub, you can find the source code...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found