Skip to content

Commit 1a43d63

Browse files
committed
application properties profile added
1 parent af3f330 commit 1a43d63

22 files changed

+100
-68
lines changed

employee-mgr/src/main/java/com/smallintro/springboot/config/SwaggerConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ private ApiInfo getApiInfo() {
2929
.title("Small Into to Spring Boot")
3030
.description("Demo Spring Boot Application's API")
3131
.version("v2.0")
32-
.contact(new Contact("Sushil Prasad","https://smallintro.com",""))
32+
.contact(new Contact("Sushil Prasad","https://smallintro.github.io",""))
3333
.license("License 2.0")
3434
.licenseUrl("https://github.com/smallintro/spring-microservice/LICENSE")
3535
.build();

employee-mgr/src/main/java/com/smallintro/springboot/controller/DefaultController.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.smallintro.springboot.controller;
22

33
import org.springframework.beans.factory.annotation.Autowired;
4+
import org.springframework.beans.factory.annotation.Value;
5+
import org.springframework.core.env.Environment;
46
import org.springframework.web.bind.annotation.GetMapping;
57
import org.springframework.web.bind.annotation.RequestHeader;
68
import org.springframework.web.bind.annotation.RequestMapping;
@@ -12,12 +14,19 @@
1214
@RequestMapping("hello")
1315
public class DefaultController {
1416

17+
@Value("${spring.application.name}")
18+
private String applicationName;
19+
20+
@Autowired
21+
private Environment env;
22+
1523
@Autowired
16-
ApplicationUtils appUtils;
24+
private ApplicationUtils appUtils;
1725

1826
@GetMapping
1927
public String getHealthStatus(@RequestHeader(name = "Accept-Language", required = false) String locale) {
20-
return appUtils.getI18nMessage("message.hello.world", locale);
28+
return appUtils.getI18nMessage("message.hello.world", locale) + " Welcome to " + applicationName + ". I am your "
29+
+ env.getProperty("info.app.name");
2130
}
2231

2332
}

employee-mgr/src/main/java/com/smallintro/springboot/controller/EmployeeController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
public class EmployeeController {
3333

3434
@Autowired
35-
EmployeeService empService;
35+
private EmployeeService empService;
3636

3737
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
3838
public List<Employee> getEmployees() {

employee-mgr/src/main/java/com/smallintro/springboot/controller/TechController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
public class TechController {
3434

3535
@Autowired
36-
TechService techService;
36+
private TechService techService;
3737

3838
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
3939
public List<Technology> getTechnologies() {

employee-mgr/src/main/java/com/smallintro/springboot/service/TechService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
public class TechService {
2424

2525
@Autowired
26-
TechRepo techRepo;
26+
private TechRepo techRepo;
2727

2828
public List<Technology> getTechnologies() {
2929
return techRepo.findAll();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#actuator
2+
management.endpoints.web.exposure.include=*
3+
management.endpoint.health.show-details=always
4+
info.app.name=Employee Manager
5+
info.app.version=v1.0
6+
# Springboot admin
7+
spring.boot.admin.client.url=http://127.0.0.1:9080
8+
spring.boot.admin.client.instance.metadata.tags.environment=dev
9+
management.matrics.export.jmx.enabled: true
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# H2
2+
spring.h2.console.enabled=true
3+
spring.h2.console.path=/h2
4+
# Datasource
5+
spring.datasource.url=jdbc:h2:file:~/empdb
6+
spring.datasource.username=sa
7+
spring.datasource.password=
8+
spring.datasource.driver-class-name=org.h2.Driver
9+
spring.jpa.show-sql = true
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Datasource
2+
spring.jpa.hibernate.ddl-auto = update
3+
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
4+
spring.datasource.username=postgres
5+
spring.datasource.password=ABC_abc1
6+
spring.datasource.driver-class-name=org.postgresql.Driver
7+
8+
#Disable trace in error response
9+
server.error.include-stacktrace=never
Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,9 @@
11
server.port=8081
2+
spring.application.name=User Service
23

4+
#Application Active DB
35

4-
# H2
5-
spring.h2.console.enabled=true
6-
spring.h2.console.path=/h2
7-
# Datasource
8-
spring.datasource.url=jdbc:h2:file:~/test
9-
spring.datasource.username=sa
10-
spring.datasource.password=
11-
spring.datasource.driver-class-name=org.h2.Driver
12-
spring.jpa.show-sql = true
13-
#spring.jpa.hibernate.ddl-auto = update
14-
#spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
15-
#spring.datasource.username=postgres
16-
#spring.datasource.password=ABC_abc1
17-
#spring.datasource.driver-class-name=org.postgresql.Driver
6+
spring.profiles.active=dev
187

19-
#Disable trace in error response
20-
server.error.include-stacktrace=never
21-
#actuator
22-
management.endpoints.web.exposure.include=*
23-
management.endpoint.health.show-details=always
24-
info.app.name=Employee Manager
25-
info.app.version=v1.0
26-
# Springboot admin
27-
spring.boot.admin.client.url=http://127.0.0.1:9080
28-
spring.boot.admin.client.instance.metadata.tags.environment=dev
29-
management.matrics.export.jmx.enabled: true
8+
#Actuator and Springboot admin
9+
spring.profiles.include=admin
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
message.hello.world="Hello World!!, I am Spring Boot Controller"
1+
message.hello.world=Hello World!!,

0 commit comments

Comments
 (0)