0% found this document useful (0 votes)
26 views28 pages

00 Vorarbeiten ÜK 295 ZH2024

Uploaded by

sexinoy702
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODP, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views28 pages

00 Vorarbeiten ÜK 295 ZH2024

Uploaded by

sexinoy702
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODP, PDF, TXT or read online on Scribd
You are on page 1/ 28

Prerequisites

üK 295 - Backend für Applikationen realisieren

TALENTE
AUSBILDEN I FÖRDERN I ENTFALTEN
• Contents
• Preface
────────────────────────────
• Docker
• Java
• PostgreSQL
• Spring Boot
────────────────────────────
• Postface

04/02/2 Noser Young 2


Prerequisites
0. Preface
• These programs also need to be installed, but the installation process
is not noteworthy
• IntelliJ: Both Community and Ultimate Edition are ok
• Postman: Default installation is sufficient

• For today, having everything installed and in a working state is more important
than knowing how to operate each tool

04/02/2 Noser Young 3


Prerequisites
1. Docker
• Install Docker Desktop
• Run Docker Desktop

• https://www.docker.com/products/docker-desktop

04/02/2 Noser Young 4


Prerequisites
1. Docker

04/02/2 Noser Young 5


Prerequisites
1. Docker

04/02/2 Noser Young 6


Prerequisites
1. Docker

04/02/2 Noser Young 7


Prerequisites
2. Java
• Java Development Kit (JDK)
• Have version 22, 21 or 17 installed

• https://jdk.java.net/archive/
• https://jdk.java.net/22/
• (Installing JDK directly from IntelliJ should also be sufficient)

04/02/2 Noser Young 8


Prerequisites
2. Java

04/02/2 Noser Young 9


Prerequisites
3. PostgreSQL
• Start a PostgreSQL Docker container
• Name: uek295db
• POSTGRES_PASSWORD=postgres
• Port: 5432

• docker run -d -p 5432:5432 -e


POSTGRES_PASSWORD=postgres --name uek295db
postgres

04/02/2 Noser Young 10


Prerequisites
3. PostgreSQL

04/02/2 Noser Young 11


Prerequisites
3. PostgreSQL
• Test the database connection
• Login from host with psql client to postgres container
psql -U postgres -h localhost -W

04/02/2 Noser Young 12


Prerequisites
4. Spring Boot
• Configure base Spring Boot project online
• Generate and download

• https://start.spring.io

• Extra info: Getting started guide:


https://spring.io/guides/gs/spring-boot/#scratch

04/02/2 Noser Young 13


Prerequisites
4. Spring Boot
• Configure exactly as shown in the screenshot below
• Choose Java version according to your installation

04/02/2 Noser Young 14


Prerequisites
4. Spring Boot
• Extract folder sbdemo01 in the ZIP file to a sensible place
• (e.g. into a folder projects-uek295)
• Open the extracted project from IntelliJ

04/02/2 Noser Young 15


Prerequisites
4. Spring Boot

04/02/2 Noser Young 16


Prerequisites
4. Spring Boot
• Start Open-Dialog
• Select folder
sbdemo01

04/02/2 Noser Young 17


Prerequisites
4. Spring Boot
• This process might take a bit, be patient!
• After that, reload all Gradle Projects
• Go to the right side and open Gradle-View, press the reload-button

2. click 1. click

04/02/2 Noser Young 18


Prerequisites
4. Spring Boot
• Again, this might take a bit
• Monitor the progress under “Build”

04/02/2 Noser Young 19


Prerequisites
4. Spring Boot
• Add the following lines to the file
• src/main/resources/application.properties

spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.hibernate.ddl-auto=create-drop
spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=postgres
spring.jpa.properties.hibernate.default_schema=public

04/02/2 Noser Young 20


Prerequisites
4. Spring Boot
• Start Spring Boot

1. click

2. click

04/02/2 Noser Young 21


Prerequisites
4. Spring Boot
• If :bootRun keeps spinning and the last entry in the console is as
shown, then the server was started successfully

04/02/2 Noser Young 22


Prerequisites
4. Spring Boot
• 1st Check Browser-Page: http://localhost:8080

04/02/2 Noser Young 23


Prerequisites
4. Spring Boot, Hello World App
• Add Java-Class HelloController to project containing:
package ch.noseryoung.sbdemo01;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

@GetMapping("/")
public String index() {
return "Greetings from Spring Boot!";
}
}

04/02/2 Noser Young 24


Prerequisites
4. Spring Boot, Hello World App

04/02/2 Noser Young 25


Prerequisites
4. Spring Boot, Hello World App
• Stop and re-run the app
• Refresh your browser

04/02/2 Noser Young 26


Prerequisites
4. Spring Boot
• You now have a basic Spring Boot application based on JDK 17 or 21
connecting to a PostgreSQL database on port 5432

• For the üK, the same Docker container can be reused. But new
projects will need to be set up accordingly

• This marks the end of the setup. Have fun! 

04/02/2 Noser Young 27


Prerequisites
Postface
• Already done setting up your environment?

• Make yourself familiar with the following terms:


• Logging (Log4j), API, Framework, Docker, Spring Boot

• Brush up your git skills and knowledge:


• https://learngitbranching.js.org/

04/02/2 Noser Young 28

You might also like