From 6e28659088f4ff8db05d97802e01c4db6a871363 Mon Sep 17 00:00:00 2001 From: Julian Horner <julianhorner@web.de> Date: Mon, 16 Dec 2019 18:40:52 +0100 Subject: [PATCH] Add eureka client to dummy-service --- pom.xml | 101 +++++++++++++----- src/main/java/de/rtuni/ms/ds/Application.java | 30 +----- src/main/resources/application.yml | 15 +++ 3 files changed, 93 insertions(+), 53 deletions(-) create mode 100644 src/main/resources/application.yml diff --git a/pom.xml b/pom.xml index 7ece7f6..0c423fd 100644 --- a/pom.xml +++ b/pom.xml @@ -8,38 +8,83 @@ <version>1.0.0</version> <packaging>war</packaging> + <name>dummy-service</name> + <description>Dummy service for microservice architecture</description> + + <properties> + <java.version>1.8</java.version> + </properties> + <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> - <version>2.2.1.RELEASE</version> + <version>2.0.0.RELEASE</version> </parent> - <dependencies> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter</artifactId> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-web</artifactId> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-tomcat</artifactId> - <scope>provided</scope> - </dependency> - </dependencies> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-data-rest</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-security</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-thymeleaf</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-tomcat</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-devtools</artifactId> + <scope>runtime</scope> + <optional>true</optional> + </dependency> + <dependency> + <groupId>org.springframework.cloud</groupId> + <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> + </dependency> + <dependency> + <groupId>io.jsonwebtoken</groupId> + <artifactId>jjwt</artifactId> + <version>0.9.0</version> + </dependency> + </dependencies> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.springframework.cloud</groupId> + <artifactId>spring-cloud-dependencies</artifactId> + <version>Finchley.RELEASE</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> - <build> - <plugins> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <version>2.2.1.RELEASE</version> - <configuration> - <mainClass>de.rtuni.ms.ds.Application</mainClass> - </configuration> - </plugin> - </plugins> - </build> + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <configuration> + <mainClass>de.rtuni.ms.ds.Application</mainClass> + </configuration> + </plugin> + </plugins> + </build> </project> \ No newline at end of file diff --git a/src/main/java/de/rtuni/ms/ds/Application.java b/src/main/java/de/rtuni/ms/ds/Application.java index 00b39b5..e41108b 100644 --- a/src/main/java/de/rtuni/ms/ds/Application.java +++ b/src/main/java/de/rtuni/ms/ds/Application.java @@ -5,19 +5,18 @@ package de.rtuni.ms.ds; -import java.util.Arrays; - -import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; +import org.springframework.cloud.netflix.eureka.EnableEurekaClient; /** + * Dummy service. + * * @author Julian * */ @SpringBootApplication +@EnableEurekaClient public class Application { //--------------------------------------------------------------------------------------------- @@ -26,26 +25,7 @@ public class Application { * * @param args The arguments */ - public static void main(final String[] args) { - SpringApplication.run(Application.class, args); - } - - //--------------------------------------------------------------------------------------------- - - @Bean - public CommandLineRunner commandLineRunner(ApplicationContext ctx) { - return args -> { + public static void main(final String[] args) { SpringApplication.run(Application.class, args); } - System.out.println("Let's inspect the beans provided by Spring Boot:"); - - String[] beanNames = ctx.getBeanDefinitionNames(); - Arrays.sort(beanNames); - for (String beanName : beanNames) { - System.out.println(beanName); - } - - }; - } - //--------------------------------------------------------------------------------------------- } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..1b7b187 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,15 @@ +# Spring properties +spring: + application: + name: dummy-service # Identify this application + +# Map the error path to error template (for Thymeleaf) +error.path: /error + +# HTTP Server +server.port: 3333 # HTTP (Tomcat) port + +eureka: + client: + serviceUrl: + defaultZone: http://localhost:8761/eureka/ \ No newline at end of file -- GitLab