diff --git a/Dockerfile b/Dockerfile
index 2221670..a763111 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -8,4 +8,4 @@ RUN mvn -B -f pom.xml clean package -DskipTests
FROM openjdk:11-jdk-slim
COPY --from=build /workspace/target/*.jar app.jar
EXPOSE 8080
-ENTRYPOINT ["java","-jar","app.jar"]
\ No newline at end of file
+ENTRYPOINT ["java","-jar","app.jar", "--spring.profiles.active=prod"]
\ No newline at end of file
diff --git a/README.md b/README.md
index d9bb166..dbead6e 100644
--- a/README.md
+++ b/README.md
@@ -19,14 +19,23 @@ In the terminal run the following command:
$ docker-compose up
```
-#### Using Maven
+#### Using Maven (with H2 or local Postgres database)
-First make sure that you adjust the configuration file - `src/main/resources/application.yml` with connection details to your database.
+First compile an application:
-Then, in the terminal run the following command:
```console
$ mvn clean package
-$ mvn spring-boot:run
+```
+
+Then, you have two options either run it with H2 database or with local Postgres database. For first approach just run:
+
+```console
+$ mvn spring-boot:run
+```
+
+For a second option, check in the configuration file - `src/main/resources/application.yml` for profile *local-postgres* if connection details are correct and if so, run the command:
+```console
+$ mvn spring-boot:run -P local-postgres
```
#### Inside IntelliJ (with H2 or Postgres database)
diff --git a/pom.xml b/pom.xml
index 380aa45..a6c4932 100644
--- a/pom.xml
+++ b/pom.xml
@@ -33,6 +33,10 @@
org.springframework.boot
spring-boot-starter
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
org.springframework.boot
spring-boot-starter-web
@@ -186,6 +190,33 @@
+
+ default
+
+ true
+
+
+ default
+
+
+
+ prod
+
+ false
+
+
+ prod
+
+
+
+ local-postgres
+
+ false
+
+
+ local-postgres
+
+
component-test
diff --git a/src/main/resources/application-h2.yml b/src/main/resources/application-h2.yml
deleted file mode 100644
index 58f108a..0000000
--- a/src/main/resources/application-h2.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-spring:
- application:
- name: library
- datasource:
- url: jdbc:h2:mem:testdb
- driverClassName: org.h2.Driver
- username: sa
- password: password
- jpa.database-platform: org.hibernate.dialect.H2Dialect
\ No newline at end of file
diff --git a/src/main/resources/application-postgres.yml b/src/main/resources/application-postgres.yml
deleted file mode 100644
index fc80752..0000000
--- a/src/main/resources/application-postgres.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-spring:
- application:
- name: library
- datasource:
- url: jdbc:postgresql://localhost:5432/library
- driverClassName: org.postgresql.Driver
- username: library
- password: library
- jpa.database-platform: org.hibernate.dialect.PostgreSQL9Dialect
\ No newline at end of file
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 08b20c4..c62c8c6 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -1,6 +1,39 @@
spring:
application:
name: library
+ profiles:
+ active: @active-profiles@
+
+
+management:
+ endpoints:
+ web:
+ exposure:
+ include: "*"
+
+---
+spring:
+ profiles: default
+ datasource:
+ url: jdbc:h2:mem:testdb
+ driverClassName: org.h2.Driver
+ username: sa
+ password: password
+ jpa.database-platform: org.hibernate.dialect.H2Dialect
+
+---
+spring:
+ profiles: local-postgres
+ datasource:
+ url: jdbc:postgresql://localhost:5432/library
+ driverClassName: org.postgresql.Driver
+ username: library
+ password: library
+ jpa.database-platform: org.hibernate.dialect.PostgreSQL9Dialect
+
+---
+spring:
+ profiles: prod
datasource:
url: jdbc:postgresql://${POSTGRES_SERVER}:5432/${POSTGRES_DB}
driverClassName: org.postgresql.Driver