-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Bart3kTK/spring_db_conf
- Loading branch information
Showing
34 changed files
with
904 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Spring Boot CI/CD Pipeline | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- spring/** | ||
pull_request: | ||
paths: | ||
- spring/** | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
mysql: | ||
image: mysql:8.0 | ||
env: | ||
MYSQL_ROOT_PASSWORD: root | ||
MYSQL_DATABASE: Weather | ||
ports: | ||
- 3306:3306 | ||
options: --health-cmd="mysqladmin ping --host 127.0.0.1 --silent" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: maven | ||
|
||
- name: Cache Maven dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.m2/repository | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- | ||
- name: Build with Maven | ||
working-directory: ./spring | ||
run: mvn clean install -DskipTests | ||
|
||
|
||
- name: Run mvn tests | ||
working-directory: ./spring | ||
run: mvn test | ||
env: | ||
SPRING_DATASOURCE_URL: jdbc:mysql://localhost:3306/Weather | ||
SPRING_DATASOURCE_USERNAME: root | ||
SPRING_DATASOURCE_PASSWORD: root | ||
|
||
- name: Spring format check | ||
working-directory: ./spring | ||
run: mvn formatter:validate | ||
env: | ||
SPRING_DATASOURCE_URL: jdbc:mysql://localhost:3306/Weather | ||
SPRING_DATASOURCE_USERNAME: root | ||
SPRING_DATASOURCE_PASSWORD: root |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"type": "java", | ||
"name": "Spring Boot-WeatherApplication<weather>", | ||
"request": "launch", | ||
"cwd": "${workspaceFolder}", | ||
"mainClass": "com.pogoda.weather.WeatherApplication", | ||
"projectName": "weather", | ||
"args": "", | ||
"envFile": "${workspaceFolder}/.env" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"java.configuration.updateBuildConfiguration": "interactive" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
CREATE DATABASE Weather; | ||
CREATE USER 'WeatherServer'@'localhost' IDENTIFIED BY 't4jn3h4sL0'; | ||
GRANT ALL PRIVILEGES ON Weather.* TO 'WeatherServer'@'localhost'; | ||
FLUSH PRIVILEGES; | ||
SHOW GRANTS FOR 'WeatherServer'@'localhost'; | ||
|
||
|
||
|
||
odpalanie: mvn spring-boot:run | ||
|
||
dopisanie w controller wiecej getow (i wiecej metod w ) | ||
|
||
stworzenie w model nowych obiektow (tych co jest w projekcie bazy danych) | ||
do nich wlasne interface | ||
i wlasne repa w data | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
spring/src/main/java/com/pogoda/weather/controller/Controller.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.pogoda.weather.controller; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.pogoda.weather.data.EspMeasurementsRepo; | ||
import com.pogoda.weather.model.EspMeasurements; | ||
|
||
import lombok.AllArgsConstructor; | ||
|
||
@AllArgsConstructor | ||
@RestController | ||
@RequestMapping("/weather") | ||
public class Controller { | ||
|
||
@Autowired | ||
EspMeasurementsRepo espDataRepo; | ||
|
||
@GetMapping("/test") | ||
public String aja() { | ||
return "cos tam"; | ||
} | ||
|
||
@PostMapping("/test") | ||
public void ajaa() { | ||
System.out.println("DOSTALEM"); | ||
} | ||
|
||
@PostMapping("/measurments") | ||
public ResponseEntity<EspMeasurements> zapis(@RequestBody EspMeasurements espMeasurements) { | ||
return ResponseEntity.ok(espDataRepo.saveMeasurements(espMeasurements)); | ||
} | ||
|
||
@GetMapping("/measurments/{id}") | ||
public ResponseEntity<EspMeasurements> odczyty(@PathVariable String id) { | ||
return ResponseEntity.ok(espDataRepo.getMeasurements(id)); | ||
} | ||
} |
Oops, something went wrong.