I’ve just developed some easy RESTful APIs but nev...
# spring
I’ve just developed some easy RESTful APIs but never done such thing 🙂
For fetching data from external services, you can use RestTemplate or, even better,
Spring WebFlux
(https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-webclient). You don't have to use reactive stack, there's
method on it that works with classical Spring MVC. For database, you can probably use simple Spring repositories: https://docs.spring.io/spring-data/data-commons/docs/current/reference/html/#repositories or use pure
if communication with a database is simple enough. JOOQ would be my choice for more advances stuff. Just google terms in
for more examples, but even URLs I've provided can get you started. And, of course, don't forget about start.spring.io to generate an initial project -- it will include all the necessary dependencies you need
Oh thanks a lot! One problem I see with spring is that there's way too many frameworks or projects in spring - isn't JOOQ another way to persisting the data?
Jooq is an ORM layer which map all the fields in database to Java class
Spring is quite huge, yes. But for what you are trying to achieve, you need boot web starter, boot webflux starter (for webclient) and some database. For example, for simple REST API with WebClient for calls towards 3rd party API and JDBC + Postgres, here's a configuration I'd use: https://start.spring.io/#!type=maven-project&language=java&platformVersion=2.3.3.RELEASE&packaging=jar&jvmVersion=11&groupId=com.example&artifactId=demo&name=demo&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.demo&dependencies=web,webflux,data-jdbc,postgresql
You can choose Gradle if you are more familiar with it than with Maven, that's also fine.