Publish Subscribe Message onto MQTT using Spring Boot

Introduction We will see an example here how to publish and subscribe message onto MQTT (Mosquitto) using Spring Boot framework. We had seen in our previous example how to publish and subscribe message using Mosquitto client – MQTT.fx. So here we are going to ingrate Spring application with MQTT broker through Spring integration framework, though the style of programming is…

Spring @ConditionalOnWebApplication and @ConditionalOnNotWebApplication Examples

Condition On Web And Not Web The Spring @ConditionalOnWebApplication and @ConditionalOnNotWebApplication annotations let configuration be included depending on whether the application is a web application. A web application is any application that uses a Spring WebApplicationContext, defines a session scope, or has a StandardServletEnvironment.

Spring @ConditionalOnExpression Example

Condition On Expression I will create examples how to work with Spring Conditional on Expression using @ConditionalOnExpression. The @ConditionalOnExpression annotation lets configuration be included based on the result of a SpEL (Spring Expression Language) expression. For this example the Module class is only loaded if a particular SpEL is enabled. This way, you might create similar modules that are only loaded if their…

Spring @ConditionalOnResource Example

Condition On Resource In this tutorial I will create examples on Spring @ConditionalOnResource. The @ConditionalOnResource annotation lets configuration be included only when a specific resource is present in the classpath. For example, the Log4j class is only loaded if the log4j configuration file (log4j.properties) was found on the class-path. This way, you might create similar modules that are only loaded if their respective…

Spring @ConditionalOnProperty Example

Condition On Property Here I will create examples on Spring conditional on property using the annotation @ConditionalOnProperty. The @ConditionalOnProperty annotation allows you to load beans conditionally depending on a certain environment property or configuration of a property. Use the prefix and name attributes to specify the property that should be checked. By default, any property that exists and is not equal…

Spring @ConditionalOnClass and @ConditionalOnMissingClass

Conditional Class Spring @ConditionalOnClass and @ConditionalOnMissingClass annotations let @Configuration classes be included based on the presence or absence of specific classes. So @ConditionalOnClass loads a bean only if a certain class is on the class path and @ConditionalOnMissingClass loads a bean only if a certain class is not on the class path. This mechanism does not apply the same way…

Spring @ConditionalOnMissingBean Example

Conditional On Missing Bean In this tutorial I will create examples on Spring @ConditionalOnMissingBean. Anywhere you define a Spring bean, you can optionally add a condition. Only if the specified condition is satisfied then only bean will be added to the application context. To declare a condition, you can use any of the @Conditional… annotations. The @ConditionalOnMissingBean annotation lets a…

Spring @ConditionalOnBean Example

Conditional On Bean I will create examples on Spring @ConditionalOnBean. Anywhere you define a Spring bean, you can optionally add a condition. Only if the specified condition is satisfied then only bean will be added to the application context. To declare a condition, you can use any of the @Conditional… annotations. The @ConditionalOnBean annotation let a bean be included based…

Implementing Caching in Spring REST Services

Introduction Here I am going to show an example on implementing caching in Spring REST web services. Caching is used to store copies of frequently accessed data in several places for the request-response path. In other words, it stores a copy of a given resource and serves it back when requested. The performance of web sites and applications can be…

Angular + Spring Boot MongoDB CRUD Example

Introduction In this post we will create Angular + Spring Boot MongoDB CRUD Example. In my previous tutorial on Spring Boot MongoDB CRUD Example, we did not have any UI or front-end, so we had to test out application using REST client but here we will use Angular on front-end side so that we can easily make this application as…