Skip to content

Commit 9cb53b0

Browse files
committed
fix: implement the use of .env file
1 parent 3679076 commit 9cb53b0

File tree

5 files changed

+22
-23
lines changed

5 files changed

+22
-23
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ To get started with the CD Job Scraper Project, follow these steps:
4848
* Ensure you have Java (Version 21) and Gradle (Version 8.5) installed.
4949
* For UNIX systems (i.e. macOS, Linux, or Windows WSL), use [SDKMAN](https://sdkman.io/) to install the correct version of Java and Gradle.
5050
* **Not recommended**: For Windows systems, install [Java 21](https://download.oracle.com/java/21/latest/jdk-21_windows-x64_bin.exe) and [Gradle 8.5](https://gradle.org/install/#manually) manually.
51-
* Set up your database and configure the connection in `application.properties`.
52-
53-
**Database Setup:**
54-
* Create a new file named `compose.yaml` in the root directory of the project (i.e. `/`).
55-
* Copy the contents of `example-compose.yaml` into `compose.yaml` and replace the placeholders with your database credentials.
56-
57-
**Application Configuration:**
58-
* Create a new file named `application.properties` in the `src/main/resources` directory.
59-
* Copy the contents of `example-application.properties` into `application.properties` and replace the placeholders with your database credentials
51+
* Set up your local environment variables: create a file called `.env` in the root directory and add the following lines:
52+
53+
```shell
54+
MYSQL_ROOT_PASSWORD=<create your own password>
55+
MYSQL_DATABASE=<name your database>
56+
MYSQL_USER=<create your own username>
57+
MYSQL_PASSWORD=<create a differnent password than ROOT_PASSWORD>
58+
MYSQL_URL=jdbc:mysql://localhost:3306/<MYSQL_DATABASE>
59+
```
6060

6161
1. **Run the Application** :
6262

compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
services:
2+
mysql:
3+
image: mysql:latest
4+
env_file: .env
5+
ports:
6+
- 3306

example.compose.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/main/resources/example.application.properties renamed to src/main/resources/application.properties

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
spring.application.name=cd-scraper
22

3+
# Read from .env file
4+
spring.config.import=file:.env[.properties]
5+
36
# Database connection properties
4-
spring.datasource.username=user
5-
spring.datasource.password=password
6-
spring.datasource.url=jdbc:mysql://localhost:3306/database
7+
spring.datasource.username=${MYSQL_USER}
8+
spring.datasource.password=${MYSQL_PASSWORD}
9+
spring.datasource.url=${MYSQL_URL}
710
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
811

912
# Docker compose properties

0 commit comments

Comments
 (0)