actuator added & spring profiles introduced
This commit is contained in:
@@ -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"]
|
||||
ENTRYPOINT ["java","-jar","app.jar", "--spring.profiles.active=prod"]
|
||||
17
README.md
17
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)
|
||||
|
||||
31
pom.xml
31
pom.xml
@@ -33,6 +33,10 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
@@ -186,6 +190,33 @@
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>default</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<properties>
|
||||
<active-profiles>default</active-profiles>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>prod</id>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
</activation>
|
||||
<properties>
|
||||
<active-profiles>prod</active-profiles>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>local-postgres</id>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
</activation>
|
||||
<properties>
|
||||
<active-profiles>local-postgres</active-profiles>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>component-test</id>
|
||||
<build>
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user