Setting the Database in MongdoDB-data-REST-complete - spring

I am using the Spring Guide for the MongoDB-data-rest-complete example and I want it to use a specific mongodb database, rather than the default one ('test'). How do I do this?

Ok I got it running! The answer is that the application.properties file may go in the src/main/resources folder!

Related

How to set up flyway default schema in Quarkus

I am checking the Quarkus guide for the flyway extension.
The default schema configuration is not listed and is not supported. I added in my application.properties
quarkus.flyway.default-schema=some_schema
quarkus.flyway.defaultSchema=some_schema
and tested, but it's not recognised. Is there a workaround or should an issue be created?
I have opened https://github.com/quarkusio/quarkus/pull/22957 to address this concern.
If all goes well, this will make it into version 2.7.0.Final.
got defaulted to
quarkus.flyway.default-schema=some_schema
just in case anyone is seeing this now

Spring cloud config fails to pick configuration from local file system

I am trying to setup spring cloud config using local file system. However, I couldn't get it working.
Below is my application.properties file:
spring.application.name=spring-cloud-config-servers
server.port=8888
spring.profiles.active=native
spring.cloud.config.server.native.searchLocations=classpath:/config
Inside limits-service.properties, I have the following:
limits-service.minimum=4
limits-service.maximum=400
Once i run the server, i get the following. Please help in fixing it.
It might be a simple mistake of naming?
For example, your spring application name is "limit-service" while your property files are named "limits-service" and that might be why it is not reading them.
yes above one it is working, spring.applicatiom.name must be equals to the properties file(Lets say uppercase must follow uppercase of properties file as well )

Can I just add an application.properties file to a Spring Boot project?

I'm fairly new to Spring Boot and MongoDB. Currently I have a project that can send data back and forth to a server that is running locally on my computer, but I want to change this and make it edit and retrieve data from an externally running database. In other tutorials I have followed I have had an application.properties file that I can edit details in to get it to connect, but I can't find this in any of the sub folders (I pulled the code from a tutorial) and I can't find anything to say that it is specifically connecting to the local instance.
Would it be okay to just create the application.properties file in the right sub folder and enter the external database's details there? Or am I going to have to try a separate method and tutorial to try and connect to the external database in another way?
I have a feeling that to answer it you will need to see/understand more of the code, but I'm not sure how to summarise anything else or what would actually be relevant. Thank you.
Spring Boot has several default folders, where it searches for properties.
One of those places is for example src/main/resources/application.properties, there you can just create this file.
An overview of other possible places for Spring Boot properties can be found here:
https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html
In my German blog I wrote an article about how to use Spring-data to access MongoDB - there I used also application.properties file:
https://agile-coding.blogspot.com/2020/10/keine-ahnung-von-mongodb-dann-nimm.html

properties file reload on change in server, Spring

i am using Spring 4.2.5 and jboss 7 server.
Is it possible to change in application.properties files and make server to reload changed data in application.properties file automatically on refresh without restarting server?
Please suggest on this. Any idea or steps or api to use anything to move forward.
Regards
Ideal way would be use spring cloud config
#EnableConfigServer. You will have separate config server pointed all the properties pointed. And a client will be able to access the properties. This allows you to change the properties on the fly in server with out need for any restart.
http://jeroenbellen.ghost.io/manage-and-reload-spring-application-properties-on-the-fly/

How to set the data directory of ElasticSearch with Spring Boot

My problem is similar to [1]
I have a spring boot appplication where I save some document in elasticsearch. The index is created in a data dir in the current directory each time. I want to change this default path to a given one. How can I do that? A such a simple task takes hours to find it out.
I tried many things:
#Setting(setting="/data/elasticsearch")
In an elasticseacrh.properties and application.properties file:
path.data
spring.data.elasticsearch.path.data
Without any luck.
Adding the path with the configuration file in my application class:
#Setting(settingPath = "/home/topic/src/main/resources/elasticsearch.properties")
Set the path.data property in the file:
path.data=/Users/mimis/Desktop/data
Did the trick.
Update:
With Spring Boot 1.3.0 we can add any Elasticsearch property in the application properties files by using the spring.data.elasticsearch.properties.* prefix. For example:
spring.data.elasticsearch.properties.data.path=/path/to/data
For me (Grails / Spring Boot 1.3.3) the following configuration works better:
spring.data.elasticsearch.properties.path.data=/path/to/data
spring.data.elasticsearch.properties.path.logs=/path/to/logs
I just ran into this issue and none of the answers provided solved it , the accept answer got the wrong property which is
spring.data.elasticsearch.properties.path.data=/path/to/data
not
spring.data.elasticsearch.properties.data.path=/path/to/data
Though with this value you will have a problem because you are writing into the root of your machine ( a mac in my case) which needs an access rights which I cannot provide so the elasticsearch template will fail to start, instead you need to set the value to
spring.data.elasticsearch.properties.path.data=path/to/data
This will create the path from the context of your application which is the root directory of your project which the application already has rights to write to it

Resources