I'm using Eclipse Neon with Spring IDE Version 3.8.3.201612191259-RELEASE.
Whenever I create an application.yml file under src/main/resources it shows with a Spring embellished icon and allows me to see Spring Boot's configuration (for example see here: https://docs.spring.io/sts/nan/v370/NewAndNoteworthy.html).
For different profiles developers can either use a single YAML file with different sections for each spring.profiles via the --- notation. Developers might also choose to use separate YAML files named with the profile as part of the name (i.e. application-dev.yml) as noted in this link: https://www.mkyong.com/spring-boot/spring-boot-profile-based-properties-and-yaml-example/ .
The functionality provided by the Spring Boot YML Editor is very helpful not only for YAML editing but also because it allows auto-complete for Spring Boot's configuration. Is there a way to associate more than one file to be see by the Spring Boot YML Editor so that I can easily edit files like application-dev.yml in that editor? I know I can right-click on the file and have it open-with Spring Yaml Properties Editor but it would be nice if similar to configuring the Spring Bean support Config Files you could also pick multiple files to be seen as Spring YAML files (or perhaps look for all application-XXX.yml files and associate them to the editor).
The place where to specify file associations for the content type Spring Yaml Properties File can be found in the Eclipse preferences in General > Content Types. Search for the content type Yaml Content Type > Spring Yaml Properties File. In the box below you can add your required file associations.
As of Eclipse Neon you have to specify all your variants, e.g. application-prod.yml, application-some-profile.yml, ...
In Eclipse Photon it will be possible to use wildcards, e.g. application-*.yml. See https://www.eclipse.org/eclipse/news/4.8/M2/ for details
Related
I have configuration files which are in HOCON (.conf) format. I would like to use Spring Cloud Config to fetch them from a BitBucket repo, and send them to an application (which is NOT a Spring application) when it boots.
I am using the "Serving Plain Text" feature of Spring Cloud Config to fetch and serve a single HOCON file, which defines a particular environment. For example, the client application requests the development.conf environment configuration file, and by specifiying it's exact path in the BitBucket repo, say myApp/development/master/development.conf, the client is served that plaintext file.
However, as is usually desired, I would like base properties from the base.conf to be included in development.conf and have values overridden by the dev enviroment property values if there are common properties in both files.
Previously there was no config server, and so by simply writing the include "base" command at the top of the development.conf file, a HOCON parser (part of the TypeSafe library) in the client app requested the base.conf file (both files being in local directories), and did the overriding when necessary.
When including a Spring Config server, development.conf can be fetched in plain text as mentioned, but it is only (as before) at the client side that the application parses the include "base" command and then refetches the base.conf file. This makes the boot phase of the app very slow (probably) because fetching the additional files requires additional authorization on BitBucket.
Question: how to make it faster?
I have tried spring.cloud.config.server.git.cloneOnStart: true, but this has apparently no improvement (maybe I'm using it incorrectly?)
Should I consider converting the .conf format to .properties format, and using spring.profiles.include: base property at the top of the new developement.properties file?
Perhaps embed the Spring server in another Spring Boot application?
I like the property overriding and inclusion feature of Spring Cloud. I just don't know how to make it work with HOCON formatted files.
I'm planning to run our own Spring Initializr instance. Is there a way to have a set of application properties get written (to application.yml) when a certain option is chosen, ideally in a separate section for each of a set of predefined profiles? I've looked into customising the project-generation process in Initializr and at creating a custom starter. I've come across auto-configuration for starters, but that seems to be about what configuration to default to when this has not been provided by properties, whereas I am after generating the properties. I've also come across an example of a custom Spring Initializr instance generating files, but I need it to modify application.yml without clobbering any other modifications that may have been made to it.
Spring Initializr (the library behind start.spring.io) does not have yaml support and does not allow you to write such file automatically when the project is generated.
It's easy enough for you to add that feature though. The way it works is through a model that contributors would tune + a writer that transform the model into the target output. An analogy of this would be MavenBuild and MavenBuildWriter that generates Maven's pom.xml.
Auto-configuration is indeed completely unrelated to code/configuration generation so no need to look there.
In Quarkus, We have properties file inside project itself called application.properties.
Is there any Quarkus way to define external properties file in my use case like i am developing a mail sender and i want to add recipients in future.
Is it possible to give application.properties outside at local and inject it at runtime?
You can add a configuration file in your application working directory under config/application.properties : https://quarkus.io/guides/config#overriding-properties-at-runtime
There is ongoing discussion to have more runtime configuration capabilities here: https://github.com/quarkusio/quarkus/issues/1218
You can achieve this by keeping .properties (or .yaml) in Spring Cloud Config Server.
It's really easy to set it up. It's is well documented in following link (official documentation):
Quarkus - Reading properties from Spring Cloud Config Server
As loïc says, you can follow the convention and create a config/application.properties. You can also use the property quarkus.config.locations to specify additional config locations. It can be defined at runtime like below
java -Dquarkus.config.locations=app-config/config.properties -jar my-app.jar
I have YAML file that has a list, the values allowed in that list are defined in an Enum in that project.
Is there anyway I can help the user with autocompletion when opening the file in intellij? I know Spring boot to do this in some way.
Such auto completion is currently not provided in YAML configuration files, but .properties files only. Please watch https://youtrack.jetbrains.com/issue/IDEA-151708 for progress.
We are thinking of migrating our Spring system to use Spring Cloud Config.
The system is made up of multiple services and some share properties for common resources such as the DB datasource. For these we have a 'base' config file which contains the commonly used properties in one place. Each of the services read the common file first and then overload their properties file on top. This saves us repeating common properties.
I can't see how we do the same with spring cloud config, I can see options for different repositories but not overloading property files.
application.yml or application.properties is common to all applications.