What are important features of using Spring Boot?
Tag: spring boot
Feign Client
Netflix provides Feign as an abstraction over REST-based calls, by which microservices can communicate with each other, but developers don’t have to bother about REST internal details. 1.Add the feign dependency to your project e.g. <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-feign</artifactId> </dependency> 2.Tell to project that we will use Feign client, so scan its annotation, add the below annotation to your application class @EnableFeignClients 3. Now, we have to create an interface where we declare the services we want to call. Please note that Service Request mapping is same as the Actual Service Rest URL. @FeignClient(name=”MySearch” ) //Service Id of service you want to call public interface MySearchServiceProxy { – – – } 4. Add or create a Controller where we autowire our Feign Interface so Spring can Inject actual implementation during runtime. @RefreshScope @RestController public class FeignMySearchController { @Autowired MySearchServiceProxy… Read more“Feign Client”
Why Spring cloud is required?
When we develop microservices with Spring Boot , we might face the below mentioned issues hence spring cloud project helps to eliminate these issues.Spring cloud is set of tools to manage and establish the service Discovery, config management and Circuit Breakers etc. It manages and handles following very efficiently, 1. Any of the network and security issues. 2. Service discovery tools manage how processes and services in a cluster can find and talk to one another. It involves a directory of services, registering services in that directory, and then being able to lookup and connect to services in that directory. 3. Redundancy issues in distributed systems. 4. Load balancing improves the distribution of workloads across multiple computing resources, such as computers, a computer cluster, network links, central processing units, or disk drives. 5. Performance issues due to various operational overheads. 6. Requirement of deployment and continuous integration.
How to integrate elastic search with spring boot application
We can use elastic search with spring boot application and for this below are the detailed steps which can be followed. (Please note there some compatibility issue with some version of elastic search hence choose the appropriate one as per your need, I have used the version 2.4.0 with my spring boot app version 1.4.0.RELEASE) 1. Download and unzip the elastic search from http://www.elastic.co/downloads/past-releases/elasticsearch-2-4-0 2. Open config file \elasticsearch-2.4.0\config\elasticsearch.yml and change the cluster name if needed, uncomment and add the value to property 3. Run the elastic search by clicking on batch file, \elasticsearch-2.4.0\bin\elasticsearch.bat (Here this is going to run the elastic search on separate server than your application i.e localhost:9300 ) 4. Add the below dependency to your spring application <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-elasticsearch</artifactId> </dependency> 5. Add the below properties to application.properties file spring.data.elasticsearch.cluster-name= spring.data.elasticsearch.cluster-nodes=localhost:9300 6. To enable the elastic search repository which will be used to save/generate/delete the search… Read more“How to integrate elastic search with spring boot application”