From Spring data JPA Spring Cloud AWS - spring-data-jpa

I'm at design phase of my project and I have a doubt.
I'm modelling my system and I will use Spring Data JPA for persistence layer. Although, there is high chances of cloud deploy. Is it traumatic the portability from Spring Data JPA to Spring Clous AWS (RDS)? I didn't find direct metion about this kind of integration.
I'm trying to avoid a waste code in future.
Best Regards,

These are actually two separate things. Spring Cloud AWS JDBC will just configure a DataSource while Spring Data JPA is going to use it.
So you can use Spring Data JPA and you will be able to move your application to AWS without much efforts (basically just changing the way the DataSource is setup).

Related

Can one setup Spring Boot 2.6 and Spring Cloud 2021.x to use Ribbon and Hystrix with Spring WebClient and Feign?

I know that Spring Cloud at some version (3.0?) dropped direct support for some Netflix libraries like Ribbon or Hystrix. Now I'm trying to make a smooth migration of around 20 microservices running on production having some custom code extending Ribbon (and Hystrix to a lesser degree). The main goal is to upgrade from Spring Boot 2.3 to 2.6. As a consequence I need to upgrade Spring Cloud to 3.1.x, right?
My guess was to proceed with 2-step upgrade to avoid a one big-step migration:
Upgrade to Spring Boot 2.6 and Spring Cloud 3.1 while still using Ribbon and Hystrix
Make a way through a jungle of an old code and getting rid of Ribbon and Hystrix in smaller increments.
However to achieve this I'm trying to use simultanously Spring Boot 2.6, Spring Cloud with release train 2021.01 and 2 selected starters from older Spring Cloud (latest versions of these artifacts):
spring-cloud-starter-netflix-hystrix 2.2.10.RELEASE
spring-cloud-starter-netflix-ribbon 2.2.10.RELEASE
Is this possible at all? We are heavilly using Feign and Spring WebClient - client-side load-balancing must work for these. So far I found out Feign clients are not automatically integrated with Ribbon.
#spencergibb #OlgaMaciaszek - especially counting on you.
Answering my own question after receiving confirmation from Spring Cloud team by other means: this is a bad idea to try use Ribbon with Spring Cloud 2021.01 and it would require a really hard work to make it working.
So short answer is: "no".

Spring data-jdbc dependencies autoconfigures Datasource and JDBCTemplate?

In a spring test there was the question:
"Would Spring Data JDBC dependency autoconfigure a Datasource and a JDBCTemplate?"
I would say no because, you need a database connector dependency like h2 or oracle right to autoconfigure a datasource? And a JDBCTemplate needs also always a datasource?
I suspect what you think is correct, also the wording is a litte off.
Strictly speaking Spring Data JDBC doesn't do any autoconfiguration at all.
Autoconfiguration is done by Spring Boot in cooperation with the Spring Boot Spring Data JDBC starter which depends on (i.e. includes the auotconfiguration done by the Spring Boot Starter JDBC
And that's the one actually autoconfiguring a Datasource and if a Datasource is available also provides/configures a JdbcTemplate.
In order to be able to configure a Datasource at the very least a JDBC Driver is required.
Depending on the environment (is it a in memory database or not, are you in a test execution or not) possibly also some configuration properties like a JDBC URL is required as well.
If you want to understand better what the conditions are for autoconfiguration I recommend the list of Spring Boot autoconfiguration classes.
If you search that list for e.g. "datasource" you'll find the relevant classes and links to their source code and annotations which I think are somewhat understandable even when you don't yet understand how Spring Boot works internally exactly.

I want to use Spring Data Rest in aws lambda without Spring Boot & tomcat

How can I use the Spring Data REST feature in AWS Lambda without using the SpringBoot dependencies which has TOMCAT and Other Heavy dependencies with it ?
My objective is to create a CRUD Lambda completely based on JSON (HATEOS - id possible)
but with minimalistic dependencies - so lambda can fire up easily
First things first: if you want to have a Lambda function which should start fast, you should not use Java (but depends on your use case). Here is a nice performance comparison between Java and Node.Js on Lambda.
If you still want to use Java and Spring Data REST, you should take a look at this AWS repository which provides a basic framework to instantiate Spring within Lambda. Based on that you should be able to add Spring Data REST.

Implementation of Spring Boot microservice using Spring Cloud

I am a beginner in Spring mvc, Spring Boot and Spring Data JPA. I am trying to create Microservices using Spring Boot. I created a sample database CRUD operation as microservice in Spring Boot. Now I have A requirement that develop a microservice using Spring Cloud.
When I referring documentation seeing Spring tools for creating application in distributed environment. I am confused about why we are using Spring Cloud? And what is actually meant by Spring Cloud? Is there any relation with Spring mvc?
Spring Cloud is for developing some of the common patterns in distributed systems.
Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed systems (e.g. configuration management, service discovery, circuit breakers, intelligent routing, micro-proxy, control bus, one-time tokens, global locks, leadership election, distributed sessions, cluster state)
Spring Cloud
For Spring Boot and Spring MVC, see this nice answer difference-between-spring-mvc-and-spring-boot

Elasticache using spring aws cloud

I am looking to implement ElastiCache(using memcached) for my spring application. From here I can see that this can be done using spring cloud aws, but I could not find proper steps for doing this anywhere. Can anyone please provide some example implementation or tutorials?
Take a look at Simple Spring Memcached (SSM) project. It provides integration with AWS Elasticache through custom annotations or Spring Cache Abstraction.