Skip to content

Commit 01737bc

Browse files
iluwatar#297 Create Spring Boot-backed Price microservice with an endpoint to retrieve a price
1 parent 0c6d3f2 commit 01737bc

File tree

4 files changed

+104
-0
lines changed

4 files changed

+104
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<relativePath>../../pom.xml</relativePath>
7+
<artifactId>java-design-patterns</artifactId>
8+
<groupId>com.iluwatar</groupId>
9+
<version>1.10.0-SNAPSHOT</version>
10+
</parent>
11+
12+
<modelVersion>4.0.0</modelVersion>
13+
<artifactId>price-microservice</artifactId>
14+
<packaging>jar</packaging>
15+
16+
<properties>
17+
<spring.version>4.2.5.RELEASE</spring.version>
18+
<spring-boot.version>1.3.3.RELEASE</spring-boot.version>
19+
</properties>
20+
21+
<dependencyManagement>
22+
<dependencies>
23+
<dependency>
24+
<groupId>org.springframework.boot</groupId>
25+
<artifactId>spring-boot-dependencies</artifactId>
26+
<version>${spring-boot.version}</version>
27+
<type>pom</type>
28+
<scope>import</scope>
29+
</dependency>
30+
</dependencies>
31+
</dependencyManagement>
32+
<dependencies>
33+
<dependency>
34+
<groupId>org.springframework</groupId>
35+
<artifactId>spring-webmvc</artifactId>
36+
<version>${spring.version}</version>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.springframework.boot</groupId>
40+
<artifactId>spring-boot-starter-web</artifactId>
41+
<version>${spring-boot.version}</version>
42+
</dependency>
43+
</dependencies>
44+
45+
<build>
46+
<plugins>
47+
<plugin>
48+
<groupId>org.springframework.boot</groupId>
49+
<artifactId>spring-boot-maven-plugin</artifactId>
50+
<version>${spring-boot.version}</version>
51+
<executions>
52+
<execution>
53+
<goals>
54+
<goal>repackage</goal>
55+
</goals>
56+
</execution>
57+
</executions>
58+
</plugin>
59+
</plugins>
60+
</build>
61+
</project>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.iluwatar.price.microservice;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
/**
7+
* PriceApplication starts up Spring Boot, exposing endpoints for the Price microservice through
8+
* the {@link PriceController}.
9+
*/
10+
@SpringBootApplication
11+
public class PriceApplication {
12+
13+
/**
14+
* Microservice entry point
15+
* @param args
16+
* command line args
17+
*/
18+
public static void main(String[] args) {
19+
SpringApplication.run(PriceApplication.class, args);
20+
}
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.iluwatar.price.microservice;
2+
3+
import org.springframework.web.bind.annotation.RequestMapping;
4+
import org.springframework.web.bind.annotation.RequestMethod;
5+
import org.springframework.web.bind.annotation.RestController;
6+
7+
/**
8+
* Exposes the Price microservice's endpoints
9+
*/
10+
@RestController
11+
public class PriceController {
12+
13+
/**
14+
* An endpoint for a user to retrieve a product's price
15+
* @return A product's price
16+
*/
17+
@RequestMapping(value = "/price", method = RequestMethod.GET)
18+
public String getPrice() {
19+
return "20";
20+
}
21+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
server.port=50006

0 commit comments

Comments
 (0)