Mvn vs. Gradle

Comparisons https://phauer.com/2018/moving-back-from-gradle-to-maven/ https://gradle.org/gradle-vs-maven-performance/ https://dzone.com/articles/gradle-vs-maven https://www.baeldung.com/ant-maven-gradle Further Gradle Info https://tomgregory.com/5-reasons-to-switch-to-the-gradle-kotlin-dsl/ https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch04.html Further Maven Info Essential Maven Plugins From https://javarevisited.blogspot.com/2016/08/top-10-maven-plugins-every-java-developer-know.html: maven-compiler-plugin: This is the most important maven plugin. You almost always use it unknowingly. This plugin compiles your Java code from the standard location Maven specifies e.g. /src/main/java and /src/main/resources. maven-surefire-plugin: The Maven Surefire plugin is the default plugin for running unit tests. You can also customize the behavior of this plugin by specifying the configuration in pom....

July 14, 2022 · 531 words · Peter Dieleman

Gradle & Java Versions

SourceCompatability vs. TargetCompatability https://stackoverflow.com/questions/16654951/gradle-sourcecompatibility-vs-targetcompatibility sourceCompatibility = JavaVersion.VERSION_11 Java Versions https://stackoverflow.com/questions/9170832/list-of-java-class-file-format-major-version-numbers gradle INVALID SOURCE RELEASE 17 https://stackoverflow.com/questions/70320448/spring-boot-gradle-build-invalid-source-release-11

July 7, 2022 · 16 words · Peter Dieleman

Avoiding NPE in filters

Sources https://stackoverflow.com/questions/32884195/filter-values-only-if-not-null-using-lambda-in-java8

May 16, 2022 · 2 words · Peter Dieleman

Best Practice Ignoring Fields from a PUT payload

Sources https://stackoverflow.com/questions/51680343/ignore-fields-from-specific-request-in-spring-boot https://stackoverflow.com/questions/12505141/only-using-jsonignore-during-serialization-but-not-deserialization https://www.concretepage.com/jackson-api/jackson-jsonignore-jsonignoreproperties-and-jsonignoretype

May 16, 2022 · 4 words · Peter Dieleman

Jackson exclude null values

Sources https://stackoverflow.com/questions/64868946/how-to-not-return-null-value-in-responseentity https://www.baeldung.com/jackson-ignore-null-fields https://stackoverflow.com/questions/11757487/how-to-tell-jackson-to-ignore-a-field-during-serialization-if-its-value-is-null Issue We have the following setting in the application.yml file, but it is ignored: spring: jackson: default-property-inclusion: non_null Manually annotating the classes with @JsonInclude(JsonInclude.Include.NON_NULL) did reinstate the wanted behaviour. However, this is painful for classes that are pulled from libraries. Root cause seems to be related to the following: https://stackoverflow.com/questions/62819472/spring-jackson-default-property-inclusion-ignored. ObjectMapper Bean in our config. Add the following: .serializationInclusion(JsonInclude.Include.NON_NULL).

May 16, 2022 · 63 words · Peter Dieleman

Feign Client converting GET to POST

Sources https://stackoverflow.com/questions/53340164/feignclient-converts-get-method-to-post https://stackoverflow.com/questions/53340164/feignclient-converts-get-method-to-post https://stackoverflow.com/questions/58468968/feign-client-get-request-throws-method-not-allowed-request-method-post-not Presence of requestbody automatically converts it to a POST

May 12, 2022 · 13 words · Peter Dieleman

Spring Validation Context

Sources https://stackoverflow.com/questions/69828371/how-to-handle-multiple-combination-of-java-bean-validation-in-spring https://www.baeldung.com/spring-mvc-custom-validator#custom-class-level-validation https://stackoverflow.com/questions/19089649/best-practices-for-validation-depending-on-actions-spring-mvc https://www.baeldung.com/javax-validation-groups https://reflectoring.io/bean-validation-with-spring-boot/#using-validation-groups-to-validate-objects-differently-for-different-use-cases

May 5, 2022 · 6 words · Peter Dieleman

Filtering on children entities

Sources https://stackoverflow.com/questions/26684361/filter-child-object-in-spring-data-query https://stackoverflow.com/questions/42857947/jpa-with-specification-how-to-filter-an-entity-by-a-child-collection-content https://stackoverflow.com/questions/47867124/spring-data-jpa-specification-how-to-filter-a-parent-object-by-its-children-obj https://www.baeldung.com/jpa-and-or-criteria-predicates?fbclid=IwAR0vao7fFrB_NghXBEesu-cCFN9HS4WfPcmCXvTkKIvO72sIWu2Nz2aST4A https://stackoverflow.com/questions/55629512/how-to-filter-parent-object-which-has-list-of-children-and-a-child-has-list-of-g https://tousu.in/qa/?qa=873798/ https://stackoverflow.com/questions/25627484/how-to-filter-child-entities-collections-with-predicate?noredirect=1&lq=1 Fetch Joins https://stackoverflow.com/questions/71840199/how-to-fix-jpa-specification-api-with-join-on-condition-returns-2-query-instead More detail - Multiselect https://www.initgrep.com/posts/java/jpa/select-values-in-criteria-queries Subquery https://stackoverflow.com/questions/53678146/jpa-2-1-predicate-criteria-for-child-entity\ Matching against a list https://stackoverflow.com/questions/13940249/jpa-criteria-api-matching-against-a-list-in-spring-data-jpa-specifications Further Info https://stackoverflow.com/questions/47469861/what-is-the-difference-between-a-criteria-a-predicate-and-a-specification

April 28, 2022 · 26 words · Peter Dieleman

Customize error message Spring Boot

Sources https://stackoverflow.com/questions/62561211/spring-responsestatusexception-does-not-return-reason https://www.baeldung.com/global-error-handler-in-a-spring-rest-api https://www.amitph.com/spring-rest-api-custom-error-messages/ https://auth0.com/blog/get-started-with-custom-error-handling-in-spring-boot-java/ https://stackoverflow.com/questions/45317638/how-to-catch-accessdeniedexception-in-spring-boot-rest-api https://stackoverflow.com/questions/59302621/custom-message-in-spring-accessdeniedexception https://dzone.com/articles/best-practice-for-exception-handling-in-spring-boo @ControllerAdvice annotation Note AccessDeniedException needs to be taken care of in filter chain

April 12, 2022 · 21 words · Peter Dieleman

Switching Spring Boot Application.yml properties from IntelliJ

Use: --spring.config.name=myproject, where myproject is the name of the *.yml or *.properties file that is stored under the default /config directory. The extension is not required. https://docs.spring.io/spring-boot/docs/2.1.13.RELEASE/reference/html/boot-features-external-config.html Further Documentation https://www.baeldung.com/spring-yaml https://baeldung-cn.com/spring-yaml-vs-properties https://docs.spring.io/spring-boot/docs/1.0.1.RELEASE/reference/html/howto-properties-and-configuration.html https://docs.spring.io/spring-boot/docs/1.0.1.RELEASE/reference/html/howto-properties-and-configuration.html#howto-change-configuration-depending-on-the-environment need: spring.config.activate.on-profile: “profile_name” example: spring: # default config without profile name . . . --- spring: config: activate: on-profile: "profile name" In conjunction with: ./gradlew run --args='--spring.profiles.active=profile_name' Can make this even more complicated when activating multiple profiles at once with overlapping properties, in that case the precedence order of profiles needs to be defined....

March 28, 2022 · 107 words · Peter Dieleman