How to set JVM settings in a Spring Boot application

The simplest way to set JVM settings in a Spring Boot application is to execute the jar file and passing the JVM settings as in the following example: $ java -Xmx32m -Xss256k -jar target/demo-app-SNAPSHOT.jar Another option is to set JVM arguments in the spring-boot-maven-plugin: For example, the following configuration suspend the process until a debugger … Read more

4 ways to bootstrap a Spring Boot Application

There are several ways to bootstrap a Spring Boot standalone application. One way to do it is by implementing the org.springframework.boot.CommandLineRunner interface and implementing the run(String… args) method. This is useful when you want to execute jobs or services, such as send a notification about the application or execute a SQL statement to update some … Read more

Passing Command Line Arguments in Spring Boot applications

Spring Boot has a quite sophisticated environment variable and config properties management. Using the @Value Annotation In general terms, you can pass arguments with -DargumentName . For example: -DargumentName=”value1″ Then in your Spring Boot application, you can retrieve the value by doing: @Value(“${argumentName}”) private String myVariable Using the @Component Bean But you can do it … Read more

Configuring SpringBoot starter parent dependency

If you open a Spring Boot project, you will see that at the top they all use a spring-boot-starter-parent as the parent in pom.xml. <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.0.RELEASE</version> <relativePath/> </parent> Parent Poms allow you to manage several aspects for the child projects such as: Dependency Management – Version of dependencies Configuration – Java Version and … Read more

Hello World con Spring Boot

Il framework Spring è stato lanciato come framework alternativo alla Java Enterprise Edition. Anziché utilizzare componenti come gli Enterprise JavaBeans con una struttura protocollare complessa, Spring ha proposto un approccio più semplice incentrato sull’iniezione delle dipendenze e sulla programmazione orientata agli aspetti (AOP) per ottenere funzionalità Enterprise dei componenti Java EE ma utilizzando semplici oggetti Java (POJO).
Il rovescio della medaglia è che anche se Spring è un framework facilmente estendibile, partendo da un core minimo, è piuttosto complesso in termini di configurazione.

Read more