I’m running on an aws-elasticsearch (with OpenSearch 1.1.x) service and im trying to connect with it from a spring application using spring-data-elasticsearch, according to the doc i configured the bean as it says. on my local i used a ssh tunnel from my aws account. i used this command: so i can connect with OpenSearch dashboard over localhost in my
Tag: spring
Checking if an object exists in a list Java Stream
I have 2 entity. One of them User, and the other one is Followers. I’m trying to make a follower system like Twitter. User can follow another user but, i want to check if user followed, don’t do it again. This is my Follower Entity : And this is the Service class : As you can see, I got the
How to count records from database and put them into List,each row represent by the letter?
I need to take values from a database and put them into a List<Long>. I made a native query but it doesn’t work correctly. Here’s a picture of the column on my database: I need to count the same statuses (“W” and “I” represent the same status but are represented by another letter). I prepared a query as shown below:
How to handle blob store url when receive from API
I have an API URL (e.g.: localhost:8080/api/blobs/download/{item-id}). The API itself will return the URL of that item in the Blob Store (for example, https://myaccount.blob.core.windows.net/mycontainer/myitem). Now I have a task that requires user to copy and paste the API URL into the browser, and expect it to view/download the item. The question is how Java can support user browse the Blob
Should I use GET or PATCH for requesting info while also updating the resource [closed]
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 1 year ago. Improve this question I am making a Blackjack service in Java using Spring, and i have methods for game moves like Hit, Stand, etc.
Convert Flux into Flux
I am working on spring webflux file upload. From the controller I want to upload the file on amazon S3 bucket. So in the controller I received following object And from the FilePart.content() I can get My question is how can I convert this Flux<DataBuffer> into Flux<ByteBuffer>. I mean into the following object Answer You can simply use the org.springframework.core.io.buffer.DataBuffer#asByteBuffer():
count non-null numbers of an object
I am making a method that can count non null value of an object, but I have an object inside another object and I have to confirm if that object is empty too, I tried with isEmpty, isNull but it says it is not empty. Object Validation method I have also tried with !ObjectUtils.isNull… Even though the “result” object has
How to mock factory method in service test with mockito
Hi I am trying to test service layer. I have already wrote tests for ConverterFactory. I think I need the mock dependency classes which ConverterServiceImpl using but Still I got NullPointerException This is my service class And this is the test This code throws error says. What am i doing wrong here?: Answer You don’t need to create a ConverterFactory
Spring Security Expression: “authenticated” vs. “isAuthenticated()”
According to the Spring Security docs, the expression to check whether a user is authenticated is isAuthenticated(). So we would do @PreAuthorize(“isAuthenticated()”), for example. However, according to the official example and confirmed by my own testing, @PreAuthorize(“authenticated”) also works. Is it a Spring Security feature or perhaps simply a Java feature (e.g. authenticated is the field that backs the getter
How to fetch data using springboot with existing mongodb collection
I have an existing mongo collection called Test collection I have created a model class for the same to fetch the data I have also created TestRepository This is my controller method But I am not able to fetch any data from mongo. I want to fetch data from the mongo collection on the basis of sequence. I have also