Kaynağa Gözat

updated file

Elliott Stansbury 5 yıl önce
ebeveyn
işleme
4d5be77424

BIN
.DS_Store Dosyayı Görüntüle


+ 42
- 10
pom.xml Dosyayı Görüntüle

10
 
10
 
11
 	<name>bakery</name>
11
 	<name>bakery</name>
12
 	<description>Demo project for Spring Boot</description>
12
 	<description>Demo project for Spring Boot</description>
13
-
14
 	<parent>
13
 	<parent>
15
 		<groupId>org.springframework.boot</groupId>
14
 		<groupId>org.springframework.boot</groupId>
16
 		<artifactId>spring-boot-starter-parent</artifactId>
15
 		<artifactId>spring-boot-starter-parent</artifactId>
17
-		<version>2.0.4.RELEASE</version>
16
+		<version>1.5.11.RELEASE</version>
18
 		<relativePath/> <!-- lookup parent from repository -->
17
 		<relativePath/> <!-- lookup parent from repository -->
19
 	</parent>
18
 	</parent>
20
 
19
 
21
-	<properties>
20
+
21
+
22
+
23
+
24
+<properties>
22
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
25
 		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
23
 		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
26
 		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
24
 		<java.version>1.8</java.version>
27
 		<java.version>1.8</java.version>
26
 
29
 
27
 	<dependencies>
30
 	<dependencies>
28
 		<dependency>
31
 		<dependency>
29
-			<groupId>org.springframework.boot</groupId>
30
-			<artifactId>spring-boot-starter</artifactId>
32
+			<groupId>org.hsqldb</groupId>
33
+			<artifactId>hsqldb</artifactId>
34
+			<scope>runtime</scope>
31
 		</dependency>
35
 		</dependency>
32
-
33
 		<dependency>
36
 		<dependency>
34
 			<groupId>org.springframework.boot</groupId>
37
 			<groupId>org.springframework.boot</groupId>
35
-			<artifactId>spring-boot-starter-data-rest</artifactId>
38
+			<artifactId>spring-boot-starter-data-jpa</artifactId>
36
 		</dependency>
39
 		</dependency>
37
 
40
 
38
 		<dependency>
41
 		<dependency>
41
 		</dependency>
44
 		</dependency>
42
 
45
 
43
 		<dependency>
46
 		<dependency>
44
-			<groupId>org.springframework.boot</groupId>
45
-			<artifactId>spring-boot-starter-test</artifactId>
46
-			<scope>test</scope>
47
+			<groupId>com.h2database</groupId>
48
+			<artifactId>h2</artifactId>
49
+		</dependency>
50
+
51
+		<dependency>
52
+			<groupId>org.hsqldb</groupId>
53
+			<artifactId>hsqldb</artifactId>
54
+			<scope>runtime</scope>
47
 		</dependency>
55
 		</dependency>
48
 		<dependency>
56
 		<dependency>
49
 			<groupId>org.springframework.data</groupId>
57
 			<groupId>org.springframework.data</groupId>
50
 			<artifactId>spring-data-commons</artifactId>
58
 			<artifactId>spring-data-commons</artifactId>
51
 			<version>1.13.10.RELEASE</version>
59
 			<version>1.13.10.RELEASE</version>
52
 		</dependency>
60
 		</dependency>
61
+		<dependency>
62
+			<groupId>org.springframework.boot</groupId>
63
+			<artifactId>spring-boot-starter-data-jpa</artifactId>
64
+			<version>2.0.4.RELEASE</version>
65
+			<scope>compile</scope>
66
+		</dependency>
67
+		<dependency>
68
+			<groupId>junit</groupId>
69
+			<artifactId>junit</artifactId>
70
+			<version>4.12</version>
71
+			<scope>test</scope>
72
+		</dependency>
73
+		<dependency>
74
+			<groupId>org.springframework</groupId>
75
+			<artifactId>spring-test</artifactId>
76
+			<version>5.1.3.RELEASE</version>
77
+			<scope>test</scope>
78
+		</dependency>
79
+		<dependency>
80
+			<groupId>org.springframework.boot</groupId>
81
+			<artifactId>spring-boot-test</artifactId>
82
+			<version>2.1.1.RELEASE</version>
83
+			<scope>test</scope>
84
+		</dependency>
53
 	</dependencies>
85
 	</dependencies>
54
 
86
 
55
 	<build>
87
 	<build>

+ 6
- 1
src/main/java/com/zipcodewilmington/bakery/Controllers/BakerController.java Dosyayı Görüntüle

2
 
2
 
3
 import com.zipcodewilmington.bakery.Models.Baker;
3
 import com.zipcodewilmington.bakery.Models.Baker;
4
 import com.zipcodewilmington.bakery.Repositories.BakerRepository;
4
 import com.zipcodewilmington.bakery.Repositories.BakerRepository;
5
+import org.springframework.beans.factory.annotation.Autowired;
5
 import org.springframework.http.HttpStatus;
6
 import org.springframework.http.HttpStatus;
6
 import org.springframework.http.ResponseEntity;
7
 import org.springframework.http.ResponseEntity;
7
-
8
+import org.springframework.web.bind.annotation.GetMapping;
9
+import org.springframework.web.bind.annotation.RestController;
10
+@RestController
8
 public class BakerController {
11
 public class BakerController {
9
 
12
 
13
+    @Autowired
10
     private BakerRepository bakerRepository;
14
     private BakerRepository bakerRepository;
11
 
15
 
16
+    @GetMapping("/make/{name}")
12
     public ResponseEntity<Iterable<Baker>> index() {
17
     public ResponseEntity<Iterable<Baker>> index() {
13
         return new ResponseEntity<>(this.bakerRepository.findAll(), HttpStatus.OK);
18
         return new ResponseEntity<>(this.bakerRepository.findAll(), HttpStatus.OK);
14
     }
19
     }

+ 6
- 0
src/main/java/com/zipcodewilmington/bakery/Controllers/MuffinController.java Dosyayı Görüntüle

2
 
2
 
3
 import com.zipcodewilmington.bakery.Models.Muffin;
3
 import com.zipcodewilmington.bakery.Models.Muffin;
4
 import com.zipcodewilmington.bakery.Repositories.MuffinRepository;
4
 import com.zipcodewilmington.bakery.Repositories.MuffinRepository;
5
+import org.springframework.beans.factory.annotation.Autowired;
5
 import org.springframework.http.HttpStatus;
6
 import org.springframework.http.HttpStatus;
6
 import org.springframework.http.ResponseEntity;
7
 import org.springframework.http.ResponseEntity;
8
+import org.springframework.web.bind.annotation.GetMapping;
9
+import org.springframework.web.bind.annotation.RestController;
7
 
10
 
11
+@RestController
8
 public class MuffinController {
12
 public class MuffinController {
9
 
13
 
14
+    @Autowired
10
     private MuffinRepository muffinRepository;
15
     private MuffinRepository muffinRepository;
11
 
16
 
17
+    @GetMapping("/make/{name}")
12
     public ResponseEntity<Iterable<Muffin>> index() {
18
     public ResponseEntity<Iterable<Muffin>> index() {
13
         return new ResponseEntity<>(this.muffinRepository.findAll(), HttpStatus.OK);
19
         return new ResponseEntity<>(this.muffinRepository.findAll(), HttpStatus.OK);
14
     }
20
     }

+ 25
- 0
src/main/java/com/zipcodewilmington/bakery/Models/Baker.java Dosyayı Görüntüle

1
 package com.zipcodewilmington.bakery.Models;
1
 package com.zipcodewilmington.bakery.Models;
2
 
2
 
3
+import org.springframework.boot.autoconfigure.domain.EntityScan;
4
+
5
+import javax.persistence.Entity;
6
+import javax.persistence.GeneratedValue;
7
+import javax.persistence.GenerationType;
8
+import javax.persistence.Id;
9
+
10
+@Entity
3
 public class Baker {
11
 public class Baker {
12
+    @Id
13
+    @GeneratedValue(strategy = GenerationType.AUTO)
14
+
4
     private Long id;
15
     private Long id;
5
 
16
 
6
     private String name;
17
     private String name;
9
 
20
 
10
     private String specialty;
21
     private String specialty;
11
 
22
 
23
+    public Baker(){
24
+
25
+    }
26
+
12
     public Baker(String name, String employeeId, String specialty) {
27
     public Baker(String name, String employeeId, String specialty) {
13
         this.name = name;
28
         this.name = name;
14
         this.employeeId = employeeId;
29
         this.employeeId = employeeId;
46
     public void setSpecialty(String specialty) {
61
     public void setSpecialty(String specialty) {
47
         this.specialty = specialty;
62
         this.specialty = specialty;
48
     }
63
     }
64
+
65
+    @Override
66
+    public String toString() {
67
+        return "Baker{" +
68
+                "id=" + id +
69
+                ", name='" + name + '\'' +
70
+                ", employeeId='" + employeeId + '\'' +
71
+                ", specialty='" + specialty + '\'' +
72
+                '}';
73
+    }
49
 }
74
 }

+ 10
- 0
src/main/java/com/zipcodewilmington/bakery/Models/Muffin.java Dosyayı Görüntüle

1
 package com.zipcodewilmington.bakery.Models;
1
 package com.zipcodewilmington.bakery.Models;
2
 
2
 
3
+import org.springframework.boot.autoconfigure.domain.EntityScan;
4
+
5
+import javax.persistence.Entity;
6
+import javax.persistence.GeneratedValue;
7
+import javax.persistence.GenerationType;
8
+import javax.persistence.Id;
9
+
10
+@Entity
3
 public class Muffin {
11
 public class Muffin {
12
+    @Id
13
+    @GeneratedValue(strategy = GenerationType.AUTO)
4
 
14
 
5
     private Long id;
15
     private Long id;
6
 
16
 

+ 2
- 0
src/main/java/com/zipcodewilmington/bakery/Repositories/BakerRepository.java Dosyayı Görüntüle

2
 
2
 
3
 import com.zipcodewilmington.bakery.Models.Baker;
3
 import com.zipcodewilmington.bakery.Models.Baker;
4
 import org.springframework.data.repository.CrudRepository;
4
 import org.springframework.data.repository.CrudRepository;
5
+import org.springframework.stereotype.Repository;
5
 
6
 
7
+@Repository
6
 public interface BakerRepository extends CrudRepository<Baker, Long> {
8
 public interface BakerRepository extends CrudRepository<Baker, Long> {
7
 }
9
 }

+ 2
- 0
src/main/java/com/zipcodewilmington/bakery/Repositories/MuffinRepository.java Dosyayı Görüntüle

2
 
2
 
3
 import com.zipcodewilmington.bakery.Models.Muffin;
3
 import com.zipcodewilmington.bakery.Models.Muffin;
4
 import org.springframework.data.repository.CrudRepository;
4
 import org.springframework.data.repository.CrudRepository;
5
+import org.springframework.stereotype.Repository;
5
 
6
 
7
+@Repository
6
 public interface MuffinRepository extends CrudRepository<Muffin, Long> {
8
 public interface MuffinRepository extends CrudRepository<Muffin, Long> {
7
 }
9
 }

+ 2
- 0
src/test/java/com/zipcodewilmington/bakery/BakeryApplicationTests.java Dosyayı Görüntüle

5
 import org.springframework.boot.test.context.SpringBootTest;
5
 import org.springframework.boot.test.context.SpringBootTest;
6
 import org.springframework.test.context.junit4.SpringRunner;
6
 import org.springframework.test.context.junit4.SpringRunner;
7
 
7
 
8
+
9
+
8
 @RunWith(SpringRunner.class)
10
 @RunWith(SpringRunner.class)
9
 @SpringBootTest
11
 @SpringBootTest
10
 public class BakeryApplicationTests {
12
 public class BakeryApplicationTests {