This is a Spring Boot based microservice example backed by PostgreSQL database. This examples shows how to do the following:
- Use
DBCP datasourcewith Java configuration. - Use
Custom Repositoryto exposeentity manager. - Insert
UUIDfield in Postgres database and generateUUIDindex. - Convert Java
Enumto PostgresEnumtype. - Convert Java
Objectto PostgresJSONBtype. - Intercation with
named native queriesandnamed stored procedure. - Custom
JsonTypeto convert a JSON string returned from a native query to a Java bean. - Use
DozerJava Bean mapper.
- You have a PostgreSQL database server running on your
localhostand in port5432. - You have a database named
postgresrunning on the server - The server has a user named
postgreswith passwordpostgres. - If any of the assumptions doesn't hold true, change the
spring.datasourceproperties in theapplication.ymlfile.
Execute the create-db.sql script under resources directory on your PostgreSQL server either using PostgreSQL administration and management tools, pgAdmin,
or from the PostgreSQL interactive terminal program, called psql.
Execute the following command from the parent directory:
mvn clean install
The main entry point jpa-postgres-jsonb example is com.basaki.example.postgres.jsonb.boot.BookApplication class.
You can start the application from an IDE by starting the BookApplication class.
. ____ _ __ _ _
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.4.5.RELEASE)
...
2017-04-16 18:32:32.947 INFO 49104 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-04-16 18:32:32.952 INFO 49104 --- [ main] c.b.e.p.jsonb.boot.BookApplication : Started BookApplication in 7.879 seconds (JVM running for 8.309)
The application starts up at port 8080.
On your browser, navigate to http://localhost:8080/ to view the Swagger.

Click the Show/Hide link to view all the operations exposed by Book API.
