I have deployed a spring boot application to Google cloud appengine service. When I run the application locally using mvn appengine:run everything works fine and I’m able to send requests to REST APIs and get expected responses back. In fact when I deploy the application to appengine I can see the application logs which indicate that server is up and
The longest Substring without Repeating Characters
I’m starting out on LeetCode, and am currently working on the problem Longest Substring Without Repeating Characters. Given a string s, find the length of the longest substring without repeating characters. Input: s = “abcabcbb” Output: 3 Explanation: The answer is “abc”, with the length of 3. I feel like my approach should work, but for some reason it fails
Unable to run jar file with –enable-preview flag when using corretto 17
I am trying to run my application in an ec2 instance using the command nohup java –enable-preview my-application.jar But somehow the –enable-preview flag is ignored and i still get an error on startup telling me that i should try running it with the flag –enable-preview. I use amazon’s corretto-17 as the openJDK version. Does corretto-17 not support the –enable-preview flag?
Can I omit try-catch?
I want to fetch an HTML page and read in with BufferedReader. So I use try-with-resources to open it handles IOException this way: Is this a good pattern to catch and instantly throw? And what if I omit try at all and state that function throws IOException? If then any potentional memory leak? Much appreciate any advice! Answer A catch
Deserialize json string with nested array of objects with dynamic key
Given the JSON string I need to convert it to my POJO named TransactionInfo JSON String POJO Additional Note (From comment) After the deserialization, I want to access different keys in the transactionProperties map. If it’s converted into a List<Map<String,String>> then it becomes complex. FYI, the keys are guaranteed to be unique so in the end, I want one single
org.springframework.dao.EmptyResultDataAccessException –>Help me fix this
I’m using this method to delete rows by giving list of ids if the given id is found it is deleted,if not it throws this EmptyResultDataAccessException help me fix this Answer Data access exception thrown when a result was expected to have at least one row (or element) but zero rows (or elements) were actually returned. Use a try-catch block
How to set different version based on profile maven
I have a java project with mvn I need to have different version based on the mvn profile How do I set version.profile based on the profile ? Answer you can create profiles like below then your default profile is demo1, and version is 1.0.0 you can use variables in profile in your maven if you want to build with
How do I cast JPA criteria Expression to long java type
This code has not compile error but at run time gets this error: Cannot cast from Expression to int I tried using String: This also gets error: ERROR: For input string: “org.hibernate.query.criteria.internal.path.SingularAttributePath@2ed2d35d”; nested exception is java.lang.NumberFormatException: For input string: “org.hibernate.query.criteria.internal.path.SingularAttributePath@2ed2d35d” Answer In your first error, you are mixing LocalDateTime.now().minusDays with the Expression root.get(“person”).get(“birthDay”).as(Long.class), and it is not possible. The error
How to make a Retrofit call Synchronously without getting Main Thread Exception?
I’m facing an issue here, and I need some help. In this application, we make Retrofit calls in the UI thread – right in the Activity -, this means that we don’t have a good architecture (i know). The problem I’m facing, is that i need to make an Synchronous GET when the user click a button, and the GET
How to send JSONArray to PHP server using Volley?
I’m fairly inexperienced with Android programming and am having issues sending a JSONArray to my PHP server. I am using the following code to generate the JSONArray from my cursor: I believe I am misunderstanding how to properly send data via JsonARrayRequest. Here is the following code that I am using to send the data. Instead of sending the data,