From be0b89e3ce73018e1fb437905e1cf26bf26a9927 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Mon, 24 Jan 2022 19:34:43 +0100 Subject: add example in spring --- .../src/main/java/it/dmi/exam/bookstore/Book.java | 69 ++++++++++++++++++++++ .../dmi/exam/bookstore/BookstoreApplication.java | 13 ++++ .../src/main/resources/application.properties | 7 +++ .../exam/bookstore/BookstoreApplicationTests.java | 13 ++++ 4 files changed, 102 insertions(+) create mode 100644 Year_3/TSDWL/SPRING/bank/bookstore/src/main/java/it/dmi/exam/bookstore/Book.java create mode 100644 Year_3/TSDWL/SPRING/bank/bookstore/src/main/java/it/dmi/exam/bookstore/BookstoreApplication.java create mode 100644 Year_3/TSDWL/SPRING/bank/bookstore/src/main/resources/application.properties create mode 100644 Year_3/TSDWL/SPRING/bank/bookstore/src/test/java/it/dmi/exam/bookstore/BookstoreApplicationTests.java (limited to 'Year_3/TSDWL/SPRING/bank/bookstore/src') diff --git a/Year_3/TSDWL/SPRING/bank/bookstore/src/main/java/it/dmi/exam/bookstore/Book.java b/Year_3/TSDWL/SPRING/bank/bookstore/src/main/java/it/dmi/exam/bookstore/Book.java new file mode 100644 index 0000000..c5b6312 --- /dev/null +++ b/Year_3/TSDWL/SPRING/bank/bookstore/src/main/java/it/dmi/exam/bookstore/Book.java @@ -0,0 +1,69 @@ +package it.dmi.exam.bookstore; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; + +import org.springframework.lang.Nullable; + +@Entity +public class Book { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column + private String name; + + @Column + private String description; + + @Nullable + private String body; + + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getBody() { + return body; + } + + public void setBody(String body) { + this.body = body; + } + + public Book() { + } + + public Book(Long id, String name, String description, String body) { + this.id = id; + this.name = name; + this.description = description; + this.body = body; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/Year_3/TSDWL/SPRING/bank/bookstore/src/main/java/it/dmi/exam/bookstore/BookstoreApplication.java b/Year_3/TSDWL/SPRING/bank/bookstore/src/main/java/it/dmi/exam/bookstore/BookstoreApplication.java new file mode 100644 index 0000000..2859579 --- /dev/null +++ b/Year_3/TSDWL/SPRING/bank/bookstore/src/main/java/it/dmi/exam/bookstore/BookstoreApplication.java @@ -0,0 +1,13 @@ +package it.dmi.exam.bookstore; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class BookstoreApplication { + + public static void main(String[] args) { + SpringApplication.run(BookstoreApplication.class, args); + } + +} diff --git a/Year_3/TSDWL/SPRING/bank/bookstore/src/main/resources/application.properties b/Year_3/TSDWL/SPRING/bank/bookstore/src/main/resources/application.properties new file mode 100644 index 0000000..30a59b8 --- /dev/null +++ b/Year_3/TSDWL/SPRING/bank/bookstore/src/main/resources/application.properties @@ -0,0 +1,7 @@ +#server.port=3000 + +spring.datasource.url=jdbc:mysql://localhost:3307/sp?serverTimezone=Europe/Rome +spring.datasource.username=root +spring.datasource.password=pass +spring.jpa.hibernate.ddl-auto=update +spring.datasource.initialization-mode=always diff --git a/Year_3/TSDWL/SPRING/bank/bookstore/src/test/java/it/dmi/exam/bookstore/BookstoreApplicationTests.java b/Year_3/TSDWL/SPRING/bank/bookstore/src/test/java/it/dmi/exam/bookstore/BookstoreApplicationTests.java new file mode 100644 index 0000000..8cccc40 --- /dev/null +++ b/Year_3/TSDWL/SPRING/bank/bookstore/src/test/java/it/dmi/exam/bookstore/BookstoreApplicationTests.java @@ -0,0 +1,13 @@ +package it.dmi.exam.bookstore; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class BookstoreApplicationTests { + + @Test + void contextLoads() { + } + +} -- cgit v1.2.3-18-g5258