How to create Springboot App with postgres using spring native graalvm? - spring

I was trying to create a CRUD app using spring boot and postgres ,alongwith spring native.But I couldn't find any proper documentation related to it apart from spring native documentation.
The part of how to integrate it with postgres,is what I am looking for.Thankyou

You can use Spring Data like you would in a standard Spring Boot application. Depending on the type of application, you can use Spring Data JDBC, Spring Data JPA (if you need the Hibernate features), or Spring Data R2DBC (for reactive apps). If you bootstrap your application from start.spring.io, you can directly select the PostgreSQL dependency from there.
To get started with Spring Data, you can refer to this guide on the Spring website: relational data access with Spring Data JDBC. It uses H2, but you can replace it with PostgreSQL. More details are available on the project documentation.
On my GitHub, you can find an example of Spring Boot application with a REST API, security, and data persistence with PostgreSQL. And packaged as a native executable through Spring Native. If you're new to Spring Native, I wrote an article about how to get started with it.

Related

Spring boot oracle database without hibernate?

i managed to connect my spring boot application with postgres without hibernate, but with r2dbc for a reactive application.
I was wondering if i can connect spring boot to oracle database without hibernate for a non reactive application ?
Spring Data provides two basic modules for integrating applications with relational databases. Spring Data JDBC is for imperative applications while Spring Data R2DBC is for reactive ones. They both use the same interfaces and patterns. If you're familiar with Spring Data R2DBC, it will be straightforward to work with Spring Data JDBC.

is spring boot only for building rest api?

and if not what are more things that we can do with spring boot?
i know that we can build a whole web app(frontend and backend) in one spring boot application in the folder resource/template and resource/static but in the real world does somebody uses this method to create web application with the resource/template and resource/static?
and one more question what is used in the real world hibernate(with the SessionFactory or EntityManager) or JpaRepository in the spring data jpa?
No Spring Boot isn't just for REST APIs.
Spring Boot is "just" a mechanism for autoconfiguring a Spring Framework based application.
Therefore you can use and it does get used for all kinds of stuff.
REST APIs for webservices
Full web application using Spring MVC
SOAP services (or are they called SOAP dispensers?)
Reactive web applications
Command line tools
Batch jobs
Swing / JavaFX applications
...
Of course there are many more people writing web applications than Swing applications with or without Spring.
The kind of web application you describe and which I put under "Full web application using Spring MVC" is a very well established model and when done right way better aligned with the principles of REST than the average so called REST service. My very personal guess is: They will still be around when nobody remembers what Angular is.
For your additional question:
Your question sounds a little like the relation between JPA and Spring Data JPA might not be completely clear.
(see Spring Data JDBC / Spring Data JPA vs Hibernate)
Both are certainly used in real world projects. By definition more projects use JPA than Spring Data JPA since the first is a superset of the later.
This involves complete Spring history,
Actual motive of Spring was to enable loose coupling , so that unit tests can be easily performed . Spring MVC was for developing web applications with Model View Controller having their proper boundaries.
Then Spring Boot which enabled developer to focus on business logic then configurations. That's why spring boot is a good choice for microservices.
For JPA or hibernate query , many people prefer using JPARepositoy as again you just have to define entity for the repository and Spring boot automatically provides you queries like findById and so on.
In short Spring boot have made it really easy to run the applications with different configurations and environment smoothly.

Spring Cloud Data Flow - can it be used without spring boot?

Can Spring Cloud Data Flow be used in Spring5 applications - NOT Spring Boot - my current employer seems to view Spring Boot applications as insecure (I've no idea why) in anyway I'd like to try use this stack for an integration project, so is it possible to use it without Spring Boot?
With Spring Cloud Data Flow you can deploy streams, tasks and batches.
This is all based on Spring, Spring Cloud and Spring Boot. Spring Boot is nothing else as a preconfigured Spring stack.
Spring Data Flow is a runitme that usually needs a cloud infrastructure like Kubernets.
I'm not sure if you really are looking for that or more for something like https://spring.io/projects/spring-integration

Spring MongoDB and GraphQL

We want to try GraphQL in our Spring based application. (its not based on spring boot). Our data repository is MongoDB. I saw various examples based on node, which makes use of graphQL + Mongo. There is also library which is with spring boot!
Can it be used directly? Or there is non spring-boot lib available?
The main thing you'd gain from Spring Boot is auto configuration for Spring Data's Mongo driver.
If you're comfortable injecting the MongoRepository into the GraphQL data sources and resolves on your own, then no, you don't need Spring Boot

Spring JPA with Jersey

I am writing a rest service using Jersey. The data access layer will be developed using Spring JPA. I will be interested to know how can I pass database properties to the Repository layer.
take a look at #Blaise Doughan's answer to a similar question
How to insert data from database with Web Service in java using JAX - RS

Resources