Showing posts with label spring. Show all posts
Showing posts with label spring. Show all posts

Monday, 17 February 2020

NoRepositoryBean annotation spring boot

import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.data.repository.Repository;
 
import java.io.Serializable;
import java.util.Optional;
 
@NoRepositoryBean
public interface BaseRepository<T, ID extends Serializable> extends Repository<T, ID> {
 
    Optional<T> deleteById(ID id);
}


Annotate the created interface with the @NoRepositoryBean annotation. This ensures that Spring Data JPA won’t try to create an implementation for the BaseRepository interface.

Monday, 25 November 2019

Generic function for Post Data with some headers in spring

 public <T,K> K postApiCall(T t, HttpHeaders headers, String url, Class<K> resposne){
        try {
            RestTemplate restTemplate = new RestTemplate();
            headers.add("Content-Type","application/json");
            HttpEntity<T> entity = new HttpEntity<T>(t, headers);
            ResponseEntity<K> result = restTemplate.exchange(url, HttpMethod.POST, entity, resposne);
            System.out.println(result.getBody());
            return result.getBody();
        }catch (Exception ee){
            ee.printStackTrace();
        }
        return null;
    }

links for Data Structure

  1) 𝐁𝐞𝐜𝐨𝐦𝐞 𝐌𝐚𝐬𝐭𝐞𝐫 𝐢𝐧 𝐋𝐢𝐧𝐤𝐞𝐝 𝐋𝐢𝐬𝐭:  https://lnkd.in/gXQux4zj 2) 𝐀𝐥𝐥 𝐭𝐲𝐩𝐞𝐬 𝐨𝐟 𝐓𝐫𝐞𝐞 𝐓𝐫𝐚𝐯𝐞𝐫𝐬𝐚𝐥𝐬...