#297 Create Spring Boot-backed Image microservice with an endpoint to retrieve an image path

This commit is contained in:
tmcconville 2016-04-02 18:19:21 -05:00
parent 3cbb88e09c
commit 0c6d3f2c3a
4 changed files with 112 additions and 0 deletions

View File

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<relativePath>../../pom.xml</relativePath>
<artifactId>java-design-patterns</artifactId>
<groupId>com.iluwatar</groupId>
<version>1.10.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>image-microservice</artifactId>
<packaging>jar</packaging>
<properties>
<spring.version>4.2.5.RELEASE</spring.version>
<spring-boot.version>1.3.3.RELEASE</spring-boot.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!--<dependencies>-->
<!--<dependency>-->
<!--<groupId>junit</groupId>-->
<!--<artifactId>junit</artifactId>-->
<!--<scope>test</scope>-->
<!--</dependency>-->
<!--</dependencies>-->
</project>

View File

@ -0,0 +1,21 @@
package com.iluwatar.image.microservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* ImageApplication starts up Spring Boot, exposing endpoints for the Image microservice through
* the {@link ImageController}.
*/
@SpringBootApplication
public class ImageApplication {
/**
* Microservice entry point
* @param args
* command line args
*/
public static void main(String[] args) {
SpringApplication.run(ImageApplication.class, args);
}
}

View File

@ -0,0 +1,21 @@
package com.iluwatar.image.microservice;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* Exposes the Image microservice's endpoints
*/
@RestController
public class ImageController {
/**
* An endpoint for a user to retrieve an image path
* @return An image path
*/
@RequestMapping(value = "/image-path", method = RequestMethod.GET)
public String getImagePath() {
return "/product-image.png";
}
}

View File

@ -0,0 +1 @@
server.port=50005