Im trying to use the file application.yml, application-dev.yml and application-prod.yml that jhipster has in the proyect, but i dont want to use this file from the proyect i want to use those file from a local path. for example C://path
Please help me
Thanks
This is purely a spring-boot mechanism not specific to JHipster.
Look at spring-boot doc for all possibilities.
In your case, you could use:
java -jar myproject.jar --spring.config.location=file:///C:/path/application-dev.yml
but the simplest is to put your yaml file in same directory as your jar file, this is what is often used in production.
Related
Is there a way to read the updated changes in application.properties without repackaging the jar in Quarkus? I could not find anything related in the official documentation at https://quarkus.io/guides/config-reference. So I am assuming that the uber jar has the application properties built in. So is there a way to override those configs while running the jar?
Edit: What I mean by overriding is: Is there a way to specify the path of the config file that the jar reads while running the jar. Something similar to java -jar app.jar -DConfig='/path/to/application.properties'.
In Quarkus some of the configurations are fixed at build time, (the once in the documentation with the lock). Others are not, this ones you can change them at runtime using several methods, for example, using environmental variables or properties in the launch commands.
Check this links for more information:
https://quarkus.io/guides/config#build-time-configuration
https://quarkus.io/guides/config-reference#configuration-sources
As you can see in the configuration-source section, quarkus will firstly search in system properties and other sources rather than in the application properties file, there is one possibility for you to change the value of your properties.
I'm currently writing a SpringBoot app implementing the CommandLineRunner.
I managed to successfully load configuration from a yaml file which can be on the on the resources folder or a file on the same path as the jar file.
I've also managed to modify the configuration in runtime however I need to persist these changes to the yaml file on the file system.
Does anybody know a "Spring way" to get it done ? or alternatively an easy way...
Thanks in advance.
You can use the FileOutputStream to write the changed file to the filesystem.
I have one maven project which wanted to have service account(json file) for authentication and maven should product the .war not .jar.
Considering that, I wanted to specify the json file location into project application.properties, like this:
spring.cloud.gcp.credentials.location=file:src/main/resources/service-account/service-account-key.json
I am new to the .war world, now the problem is when i build the project locally I am able to get the json file as it is in my resource folder and I am using tomcat locally which is working fine.
But in case of when i deploy into google app engine and its war nature service-account-key.json file is not found on the mentioned location.
Can anyone help on the same, where i need to put in for that as a part of build only i can refer and use the service account json file at both the time locally and after deploy as well.
thanks for you help in advance.
According to Google Cloud documentation you have two choices for providing the credentials to your application:
1. Set the GOOGLE_APPLICATION_CREDENTIALS environment variable explicitly.
2. Pass the path to the service account in code.
You can check this link for more information: https://cloud.google.com/docs/authentication/production#auth-cloud-implicit-java
You can reference the file in resources by prepending classpath: instead of file:
See my answer here.
I have a Java Project which includes a config.properties file, in which this config.properties file has property values of paths to some executable files.
I've configured a Git Repository (using EGit eclipse) tool, but the application is simply not working due to the fact that the config.properties file is not included in the Git Repository (in gitignore) since all users who will push/pull to Git will have a different config.properties file. How shall I solve this problem? Is there a way to map the config file without including it to the repository.
Any help is highly appreciated, and I'm quite sure theres a solutions to this problem. 'Thanks in advance.
A way could be to gitignore config.properties, and add a config.properties-template with all parameters and comments explaining how to fill them if needed.
Solved. What I did was to include a piece of code whick will create a config.properties file with default values if none are found. –
I was thinking to use log4j for my standalone java project.
Is it possible to use it for java project(not a web app).
If its possible then how should I be able to initialize the properties file and where should
I put the properties file(directory structure).
Any help is appreciated.
Yes, it is possible, we do it all the time. You just need a log4j.properties file on your classpath, which in most cases means in the base directory of your jar file. If you wish to have multiple properties files with differing configurations, you can create a properties configurator in some entry point before your first logging statement.
Yes it's possible.
If you're planning to create a jar file.
Make sure that your log4j.properties is found in your classes folder in jar file.
Make sure that your log4j jar is included in your classpath.
Enjoy!
It's definitly possible to use log4j in a standalone project. Just set your classpath to include the log4j jar. As for the properties file, the apache documentation should say where to log4j looks for it (it's probably also configurable).