@@ -30,27 +30,55 @@ The interactive API documentation is available via **Swagger UI / OpenAPI**.
3030
3131## ⚙️ Configuration
3232
33- The main configuration file is located at:
33+
34+ The main configuration file is:
3435
3536```
3637src/main/resources/application.properties
3738```
3839
39- ### Properties to configure
40+ But for credentials and local overrides, use:
41+
42+ ```
43+ src/main/resources/application-local.properties
44+ ```
45+
46+ ### Example for application.properties
4047
4148``` properties
4249spring.application.name =spring_boot_java_random_user
43-
44- # Swagger UI — available at /api
4550springdoc.swagger-ui.path =/api
46-
47- # PostgreSQL datasource (add these if you use persistence)
4851spring.datasource.url =jdbc:postgresql://localhost:5432/<database_name>
49- spring.datasource.username =<username>
50- spring.datasource.password =<password>
5152spring.datasource.driver-class-name =org.postgresql.Driver
5253```
5354
55+ ### Local credentials & security
56+
57+ To avoid exposing database credentials in source code, create a ` .env ` file at the project root (not versioned):
58+
59+ ```
60+ DB_USER=postgres
61+ DB_PASSWORD=postgres
62+ ```
63+
64+ Then, in ` src/main/resources/application-local.properties ` :
65+
66+ ``` properties
67+ spring.datasource.username =${DB_USER}
68+ spring.datasource.password =${DB_PASSWORD}
69+ ```
70+
71+ Both ` .env ` and ` application-local.properties ` are in ` .gitignore ` (already set).
72+
73+ To activate the local profile in IntelliJ or VS Code, add this environment variable to your run configuration:
74+
75+ ```
76+ SPRING_PROFILES_ACTIVE=local
77+ ```
78+
79+ This way, each developer can use their own credentials without risk of leaking them to GitHub.
80+
81+
5482> ⚠️ ** Common startup error** :
5583> ```
5684> Failed to configure a DataSource: 'url' attribute is not specified
@@ -218,7 +246,7 @@ This project consumes the public **Random User Generator** API:
218246
219247- [x] [ Add Sonarqube in the project] ( https://github.com/XPEHO/spring_boot_java_random_user/issues/2 )
220248- [ ] [ Add PostgreSQL database with docker] ( https://github.com/XPEHO/spring_boot_java_random_user/issues/6 )
221- - [X] [ Add this endpoint get /user/ random] ( https://github.com/XPEHO/spring_boot_java_random_user/issues/5 )
249+ - [X] [ Add this endpoint get /random-users ] ( https://github.com/XPEHO/spring_boot_java_random_user/issues/5 )
222250- [ ] [ Add this endpoint get /user/{id}] ( https://github.com/XPEHO/spring_boot_java_random_user/issues/8 )
223251- [ ] [ Add this endpoint put /user/{id}] ( https://github.com/XPEHO/spring_boot_java_random_user/issues/9 )
224252- [ ] [ Add this endpoint delete /user/{id}] ( https://github.com/XPEHO/spring_boot_java_random_user/issues/10 )
0 commit comments