Quantcast
Browsing all 49 articles
Browse latest View live

Answer by blacktide for Best practices for storing passwords when using...

You should use environment variables in your application.properties file for this:spring.datasource.username=${SPRING_DATASOURCE_USERNAME}spring.datasource.password=${SPRING_DATASOURCE_PASSWORD}Or with...

View Article


Answer by blacktide for How To Pass Two @RequestBody from Postman (springboot)

You can define your request body as an array like the following:public ResponseEntity<String> enroll(@RequestBody Course[] courses) { // use courses array here}

View Article


Answer by blacktide for Change all letters except space from a string using Java

You can use the \\S regex:String s = "Sonra görüşürüz";String replaced = s.replaceAll("\\S", "-");System.out.println(replaced); // outputs ----- ---------

View Article

Answer by blacktide for Java - Cannot get loop to recognize newly generated...

As your code currently stands, you're only parsing the user's input the first time. Inside the loop you're reading the user's input again, but you're not updating the words variable based on the new...

View Article

Answer by blacktide for AlgoExpert Question, Tournament Winner, Not passing...

You should use containsKey on your Hashtable instead of contains on this line:if (!tableTeamNameAndPoints.contains(winningTeamName)) {When you use contains, you're checking if the Hashtable contains a...

View Article


Answer by blacktide for Kubernetes - create secret with a label using cli in...

There isn't an option in the kubectl create secret command to add a label.You will need to run a second command to add the label:kubectl label secret my-secret -n myns "foo=bar"But you could...

View Article

Answer by blacktide for How do I switch between contexts in K9s when the...

You can switch to another context by typing :ctx <context-name>. For example:# Switch to the PROD context:ctx PROD# Switch to the NONPROD context:ctx NONPRODA full list of commands and...

View Article

Answer by blacktide for Using Java's Timer to wait for a period of time...

The reason why it seems to be looping infinitely, is because the myIterator.next() call doesn't happen until the TimerTask is executed, so myIterator.hasNext() is not updating on each loop iteration....

View Article


Answer by blacktide for Preventing text in rt tags (furigana) from being...

You can achieve this with CSS by using the user-select property. You can try it below:rt { -webkit-touch-callout: none; /* iOS Safari */ -webkit-user-select: none; /* Safari */ -khtml-user-select:...

View Article


Answer by blacktide for Error with Lombok's @Builder with generic typed field

To resolve the compilation error, you should define the generic when calling the builder() method like so:OperationResult<String> result = OperationResult.<String>builder() .data("Test")...

View Article

Answer by blacktide for How to write Pipeline to discard old builds?

If you're using the Jenkins Job DSL to create a job or pipelineJob, you can use any of the following formats to add the discard builds configuration to your job:Option 1This option modifies the XML...

View Article

Answer by blacktide for Find elements by multiple class names in Selenium Java

Only one class name can be used with the By.className(String) method. From the JavaDoc:Find elements based on the value of the "class" attribute. Only one class name should be used. If an element has...

View Article

Answer by blacktide for Convert a single-threaded calculation to...

You can use the Executors.newFixedThreadPool(int) method to get an ExecutorService to submit tasks to.Each task that you submit to the thread pool will return a Future, which you can maintain a list of...

View Article


Answer by blacktide for Why Junit fails to perform dependency injection in test?

Your final code block is correct and is the standard practice, you don't need a constructor in this test class for the Calculator instance.For the test class you should define the fields and initialize...

View Article

Image may be NSFW.
Clik here to view.

Answer by blacktide for JMH Unable to find the resource: /META-INF/BenchmarkList

If anyone is using Gradle, add the jmh-gradle-plugin to your plugins block:plugins { id 'java' id 'me.champeau.jmh' version '0.6.8'}Then add all of the following in your dependencies block (check the...

View Article


Answer by blacktide for Kotlin -> Java API call is not using the method I...

In Kotlin Array<Int> is a Integer[] under the hood, and IntArray is an int[] (see here).To resolve the issue, you can change c to c.toIntArray() on the last line:targetJdbcTemplate.update(sql, p,...

View Article

Answer by blacktide for Unit testing c++. How to test private members?

Another solution that doesn't require you to add any gtest headers or macros to your production code could be to mark the private members as protected and create a derived class used in your tests with...

View Article


Image may be NSFW.
Clik here to view.

Answer by blacktide for picocli: show help if no parameter given

You can also do this with CommandSpec, as shown in the Git example in the picocli-examples repository. Just add spec.commandLine().usage(System.err) to the call()/run() method of your top-level...

View Article

Answer by blacktide for How to delete a file after sending it in a web app?

Here's a simple way using StreamingResponseBody from your controller method:File file = getFile();return ResponseEntity.ok() .headers(headers) .contentLength(length)...

View Article

Answer by blacktide for java.lang.NoClassDefFoundError:...

It seems that the docker-java-api dependency is not included with the docker-java dependency.If you add this dependency to your pom.xml it should resolve the...

View Article
Browsing all 49 articles
Browse latest View live