How to write key values to Consul In the first example we are going to use the HTTP API directly, in the second one we are going to use the Java Consul API ecwid. On Github you’ll find all the examples. So, let’s start. HTTP APIIn this example we store the value „buon giorno“ with …
Kategorie-Archiv: Java
@apiNote, @implSpec and @implNote with Gradle
How-to build JavaDoc In this post, I explain to you how you can build JavaDoc with the new tags @apiNote, @implSpec and @implNote with Gradle. Prior to the new tags, the „JavaDoc“ always consisted of documentation about implementation and informative notes in a mixed way. With @apiNote, @implSpec and @implNote you can place different kinds …
Spring Actuator Metrics availableTags
Get useful metrics to monitor your app With Spring Actuator API several useful metrics can be exposed that you can use to monitor your Spring Boot application. Metrics like application health or the last HTTP requests. I’ll show you how to do that. I’ve made an example project you can found at https://github.com/claudioaltamura/docker-springboot-helloworld. After starting …
Discover updates or vulnerabilities
Keep your dependencies up-to-date with gradle This is an import task, e.g. nearly every 6 months major releases of frameworks are available or new vulnerabilities are found on a daily basis. I’ll show you two gradle plugins which helps you that your software project won’t be left behind. The first one is gradle-version-plugin. This plugin …
Never write in Java a getter or equals method again
The lombok project helps you to be more productive Lombok is a great tool. Your code often gets verbose for common tasks. So what does lombok? The framework is plugged into the build process. It autogenerates bytecode into your class fields through a couple of annotations. Here comes the build.gradle: So let’s have a look …
„Never write in Java a getter or equals method again“ weiterlesen
Trace http requests with Spring Actuator
List the last http request with ease Spring Actuator provides also a httptrace endpoint. You get the last HTTP request with /httptrace. After adding Spring Boot Actuator dependencies to your project dependencies, you have to expose the httptrace endpoint via your application.properties: [code]management.endpoints.web.exposure.include=httptrace[/code] [code] curl http://127.0.0.1:8080/actuator/httptrace | jq { "traces": [{ "timestamp": "2019-01-05T07:45:14.406Z", "principal": null, …
Change your application log level with Spring Actuator
You can do it even at runtime 🙂 Spring Boot provides a loggers actuator endpoint for viewing and changing log levels at runtime. What do I need? Add the Spring Boot Starter Actuator to you pom.xml or build.gradleorg.springframework.boot:spring-boot-starter-actuator Expose at least the loggers endpoint in your application.propertiesmanagement.endpoints.web.exposure.include=loggers When exposed, you get all loggers details with /loggers: …
„Change your application log level with Spring Actuator“ weiterlesen
Workaround – No tests found with Testrunner JUnit 5
Java 8, Eclipse, JUnit 5 & Gradle It seems to be a bug in Eclipse and it’is fixed in the Oxgen Release 3 (4.7.3). But I still have the problem in my Java 8 project. So I did a little trick. I changed the version for the engine and the launcher back to 5.1.0. [code] …
„Workaround – No tests found with Testrunner JUnit 5“ weiterlesen
Calculate memory usage of Java objects
With Twitter’s ObjectSizeCalculator If you are looking for an easy way to estimate the object size than this could interest you. [code] // gradle dependency // https://mvnrepository.com/artifact/com.twitter.common/objectsize compile group: ‚com.twitter.common‘, name: ‚objectsize‘, version: ‚0.0.12‘ System.out.println( ObjectSizeCalculator.getObjectSize(myObject) ); [/code] The memory size of your object depends on the architecture, the actual vm implementation and whether the …
Embedded Jetty with Servlet and Annotations
How do I programmatically configure Jetty that I can use Servlet Annotations? If you doing just servlets with jetty, this article could be interesting for you. I show you how I did it. Here comes the configuration: [code] … server = new Server(port); server.addBean(LOG); WebAppContext webAppContext = new WebAppContext(); webAppContext.setContextPath("/"); String webxmlLocation = JettyServer.class.getResource("/webapp/WEB-INF/web.xml").toString(); webAppContext.setDescriptor(webxmlLocation); …