Tag java
Spring Boot: 'junit-vintage' failed to discover tests
When Using Only JUnit5 Tests (2 mins read).
How to avoid the error 'junit-vintage' failed to discover tests
when using Spring Boot.
Spring Boot Hello World Example - Thymeleaf - Mkyong.com
Recommended read: Spring Boot Hello World Example - Thymeleaf - Mkyong.com https://mkyong.com/spring-boot/spring-boot-hello-world-example-thymeleaf/
Using @Mock
as a Method Parameter with Mockito (2 mins read).
Using @Mock
on method parameters to reduce manual mock setups with Mockito.
Keeping Track of Certificate Expiry with a JWKS to iCalendar Converter (4 mins read).
Creating an iCalendar feed for certificate expiry details, given a URI for a JSON Web Key Set.
How to Run Java on the Command-Line to Attach a Debugger (1 mins read).
How to run java
on the command-line, and make it possible to attach a debugger.
Extract a Public Cert from a Java Keystore/Truststore (1 mins read).
How to export the public certificate from a Java keystore.
Evicting Spring Cache on a Schedule (1 mins read).
How to evict Spring Cache's @Cacheable
data on a schedule.
Found this out today, via a colleague, as a good way for your Java library to expose information about the API stability / intent behind classes.
Recommended read: `@API` Guardian https://github.com/apiguardian-team/apiguardian
How to avoid HttpMessageNotReadableException
when using ContentCachingRequestWrapper
with Java Servlet Filters (1 mins read).
How to avoid receiving Required request body is missing
errors when using a ContentCachingRequestWrapper
.
Reading a Servlet/Spring Request Body Multiple Times (3 mins read).
How to read the request body more than once using Java Servlet Filters.
Disabling @Valid
Annotation in a Spring Integration Test (1 mins read).
How to disable @Valid
validation in Spring Integration Tests.
#Java friends testing using #RestAssured, you may enjoy my article https://www.jvt.me/posts/2020/05/18/rest-assured-curl/ which can help you convert its logs to curl
requests, for cases you need to do some manual testing, too
Running Spotless Automagically with Gradle (2 mins read).
How to set Gradle configuration globally to always run spotlessApply
in your projects.
java - How to disable spring security for particular url - Stack Overflow
Recommended read: java - How to disable spring security for particular url - Stack Overflow https://stackoverflow.com/questions/30366405/how-to-disable-spring-security-for-particular-url/30366773#30366773
AWS Lambda Java Tutorial: Best Practices to Lower Cold Starts
Recommended read: AWS Lambda Java Tutorial: Best Practices to Lower Cold Starts https://www.capitalone.com/tech/cloud/aws-lambda-java-tutorial-reduce-cold-starts/
How to resolve "Can't start redis server. Check logs for details" with embedded-redis
Recommended read: How to resolve "Can't start redis server. Check logs for details" with embedded-redis https://github.com/kstyrc/embedded-redis/issues/51#issuecomment-549726148
Recommended read: Java records demystified https://isank.dev/posts/java-14-records/
Announcing the Spring Authorization Server
Recommended read: Announcing the Spring Authorization Server https://spring.io/blog/2020/04/15/announcing-the-spring-authorization-server
Tomcat May Log Cookies Out-of-the-Box (3 mins read).
Warning you about cookies being logged out-of-the-box, and how to resolve it.
Providing Custom Serialization for Map
Keys in Jackson (1 mins read).
How to configure Jackson to use a custom method to serialise keys for a Map
.
Comparison table of Java's `HttpServletFilter`'s methods
Recommended read: Comparison table of Java's `HttpServletFilter`'s methods https://stackoverflow.com/questions/4931323/whats-the-difference-between-getrequesturi-and-getpathinfo-methods-in-httpservl/21046620#21046620
Extract a Private Key from a Java Keystore (1 mins read).
How to export an asymmetric PrivateKeyEntry
entry from a Java keystore.
Recommended read: That upgrade from Java 8 to 11 you've been putting off? UK fintech types at Revolut 'quite happy' after a year in production https://www.theregister.co.uk/2020/03/17/that_upgrade_from_java_8_to_11_revolut_quite_happy_after_a_year_in_production/
How to unzip/decompress a Java JAR file (1 mins read).
How we can use the unzip
command to decompress JAR files.
Generating HMAC Signatures on the Command Line with OpenSSL (1 mins read).
How to generate HMAC signatures for a given string, using openssl
.
Meant to share this a couple of weeks ago - this is really great, and was very timely after a presentation from a colleague about #Kotlin, and the fact that the data
class that Kotlin has is very cool. Still a while away from my own Java code but interesting nonetheless!
Recommended read: Records Come to Java https://blogs.oracle.com/javamagazine/records-come-to-java
Generate Plain Old Java Objects (POJOs) from XML Schema Definitions with xjc
(4 mins read).
How to generate POJOs really quickly and easily, with no manual work, using the xjc
command.
What's the best way to build a string of delimited items in Java?
Recommended read: What's the best way to build a string of delimited items in Java? https://stackoverflow.com/a/63258
First look at Cloud Native Buildpacks support in Spring Boot 2.3 Milestone 1
This is very cool. I've been thinking about containerising my personal APIs for this site, and I guess this would remove a lot of the work! Looking forward to playing with this once it's released.
Recommended read: First look at Cloud Native Buildpacks support in Spring Boot 2.3 Milestone 1 https://medium.com/@TimvanBaarsen/first-look-at-cloud-native-buildpacks-support-in-spring-boot-2-3-milestone-1-ece8e72ed93f
This is very interesting to hear just days after a colleague gives a compelling introduction to Kotlin of which one key selling point (to me at least) is reducing boilerplate for Plain Old Java Objects (POJOs) that are effectively data-only objects.
That being said, it's still a way off compared to Java 8, and could be nice to try out Kotlin a bit more.
Recommended read: Records Come to Java https://blogs.oracle.com/javamagazine/records-come-to-java
Actuator HTTP Trace Does Not Work With Spring Boot 2.2.x
Recommended read: Actuator HTTP Trace Does Not Work With Spring Boot 2.2.x https://juplo.de/actuator-httptrace-does-not-work-with-spring-boot-2-2/
Performing Mutual TLS Authentication with Rest Assured (via Apache HTTP Client) (3 mins read).
How to configure Rest Assured to perform Mutual TLS authentication against an API.
2018 in Review (25 mins read).
Looking back at 2018 as a whole - both the positives and negatives, and looking forward to 2019.
Gotcha: Running both JUnit4 and JUnit5 Together with Gradle (1 mins read).
How to make sure your JUnit4 and JUnit5 Gradle tests work within the same project.
Gotcha: Running both JUnit4 and JUnit5 Together with Maven (1 mins read).
How to make sure your JUnit4 and JUnit5 Maven tests work within the same project.
Warning about Java's `DateTimeFormatter`
A subtle and not so fun source of bugs if you're affected - worth investigating!
Recommended read: Warning about Java's `DateTimeFormatter` https://twitter.com/NmVAson/status/1207820284268597249
Setting Your Maven Project Versions (1 mins read).
How to set the versions of all Maven pom.xml
s within a Maven project.
Listing the Contents of a Java Truststore (3 mins read).
How to extract a list of trusted certificates from a Java Trust store.
Don't Put Fat Jars in Docker Images
Recommended read: Don't Put Fat Jars in Docker Images https://phauer.com/2019/no-fat-jar-in-docker-image/
Testing Your SLF4J Logs (3 mins read).
Looking at how we would unit test our SLF4J logs to gain confidence they work, and to catch regressions in the future.
Extracting Request Parameters Dynamically for a application/x-www-form-urlencoded
Request (1 mins read).
How to access all key-value pairs of parameters sent in a application/x-www-form-urlencoded
request.
Extracting Request Parameters Dynamically for a multipart/form-data
Request (2 mins read).
How to access all key-value pairs of parameters sent in a multipart/form-data
request.
Extract a Secret Key from a Java Keystore (2 mins read).
How to export a symmetric SecretKey
entry from a Java keystore.
Verify if a field in a JSON response is not set with Rest Assured (1 mins read).
How to verify whether a field is not present in a JSON Rest Assured Response
.
Pretty Print JSON with Java (1 mins read).
How to pretty print a JSON object using Java and Jackson.
Gotcha: URL Encoding for consecutive double slashes issue with Rest Assured (2 mins read).
How to workaround consecutive double slashes being URL encoded (as %2F
s) in Rest Assured.
Prettier HTML Reports for Cucumber-JVM (2 mins read).
How to generate prettier HTML reports for Cucumber with cucumber-reporting
and cucumber-reporting-plugin
, with and without Jenkins.
Creating a versionable, self-contained (fat-/uber-) JAR for Gatling tests (17 mins read).
Why you'd want a fat JAR for your Gatling tests and how you'd achieve it.
Creating a versionable, self-contained (fat-/uber-) JAR for Cucumber tests (11 mins read).
Why you'd want a fat JAR and how you'd achieve it.