JAVA-38 Move all Spring Cloud Modules to Boot 2

This commit is contained in:
mikr 2020-07-15 22:12:07 +02:00
parent c3baa7b0a3
commit 7015c66691
14 changed files with 47 additions and 32 deletions

View File

@ -31,6 +31,7 @@
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>${rest-assured.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@ -10,9 +10,9 @@
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
<artifactId>parent-boot-2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../parent-boot-2</relativePath>
</parent>
<modules>
@ -56,17 +56,15 @@
</build>
<properties>
<spring-session.version>1.2.2.RELEASE</spring-session.version>
<spring-cloud-dependencies.version>Brixton.SR7</spring-cloud-dependencies.version>
<spring-cloud-starter-config.version>1.2.2.RELEASE</spring-cloud-starter-config.version>
<spring-cloud-config-server.version>1.2.2.RELEASE</spring-cloud-config-server.version>
<spring-cloud-starter-eureka.version>2.0.2.RELEASE</spring-cloud-starter-eureka.version>
<spring-cloud-starter-feign.version>1.4.6.RELEASE</spring-cloud-starter-feign.version>
<spring-cloud-starter-hystrix.version>1.2.3.RELEASE</spring-cloud-starter-hystrix.version>
<spring-cloud-stream.version>1.3.0.RELEASE</spring-cloud-stream.version>
<spring-boot-starter-web.version>1.4.2.RELEASE</spring-boot-starter-web.version>
<spring-boot-maven-plugin.version>1.4.2.RELEASE</spring-boot-maven-plugin.version>
<spring-cloud-starter-zuul.version>1.2.3.RELEASE</spring-cloud-starter-zuul.version>
<spring-cloud-dependencies.version>Hoxton.SR4</spring-cloud-dependencies.version>
<spring-cloud-starter-config.version>2.2.3.RELEASE</spring-cloud-starter-config.version>
<spring-cloud-config-server.version>2.2.3.RELEASE</spring-cloud-config-server.version>
<spring-cloud-starter-eureka.version>1.4.7.RELEASE</spring-cloud-starter-eureka.version>
<spring-cloud-starter-feign.version>1.4.7.RELEASE</spring-cloud-starter-feign.version>
<spring-cloud-starter-hystrix.version>1.4.7.RELEASE</spring-cloud-starter-hystrix.version>
<spring-cloud-stream.version>3.0.6.RELEASE</spring-cloud-stream.version>
<spring-boot-starter-web.version>2.3.1.RELEASE</spring-boot-starter-web.version>
<spring-boot-maven-plugin.version>2.3.1.RELEASE</spring-boot-maven-plugin.version>
</properties>
</project>

View File

@ -4,12 +4,14 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import static org.springframework.boot.WebApplicationType.NONE;
@SpringBootApplication
@EnableDiscoveryClient
public class DiscoveryClientApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(DiscoveryClientApplication.class).web(true)
new SpringApplicationBuilder(DiscoveryClientApplication.class).web(NONE)
.run(args);
}

View File

@ -1,13 +1,16 @@
package com.baeldung.spring.cloud.consul.health;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import static org.springframework.boot.WebApplicationType.NONE;
@SpringBootApplication
public class ServiceDiscoveryApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(ServiceDiscoveryApplication.class).web(true)
new SpringApplicationBuilder(ServiceDiscoveryApplication.class).web(NONE)
.run(args);
}

View File

@ -4,12 +4,14 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.web.bind.annotation.RestController;
import static org.springframework.boot.WebApplicationType.NONE;
@SpringBootApplication
@RestController
public class DistributedPropertiesApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(DistributedPropertiesApplication.class).web(true)
new SpringApplicationBuilder(DistributedPropertiesApplication.class).web(NONE)
.run(args);
}

View File

@ -36,18 +36,22 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix</artifactId>
<version>${spring-cloud-starter-hystrix.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-hystrix-dashboard</artifactId>
<version>${spring-cloud-starter-hystrix.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-feign</artifactId>
<version>${spring-cloud-starter-feign.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>${spring-boot-starter-web.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@ -1,7 +1,7 @@
package com.baeldung.spring.cloud.hystrix.rest.consumer;
import com.baeldung.spring.cloud.hystrix.rest.producer.GreetingController;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;

View File

@ -3,8 +3,8 @@ package com.baeldung.spring.cloud.hystrix.rest.consumer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableCircuitBreaker

View File

@ -28,13 +28,13 @@ public class MultipleOutputsServiceApplicationIntegrationTest {
@Test
public void whenSendMessage_thenResponseIsInAOutput() {
whenSendMessage(1);
thenPayloadInChannelIs(pipe.anOutput(), 1);
thenPayloadInChannelIs(pipe.anOutput(), "1");
}
@Test
public void whenSendMessage_thenResponseIsInAnotherOutput() {
whenSendMessage(11);
thenPayloadInChannelIs(pipe.anotherOutput(), 11);
thenPayloadInChannelIs(pipe.anotherOutput(), "11");
}
private void whenSendMessage(Integer val) {
@ -43,7 +43,7 @@ public class MultipleOutputsServiceApplicationIntegrationTest {
.build());
}
private void thenPayloadInChannelIs(MessageChannel channel, Integer expectedValue) {
private void thenPayloadInChannelIs(MessageChannel channel, String expectedValue) {
Object payload = messageCollector.forChannel(channel)
.poll()
.getPayload();

View File

@ -28,13 +28,13 @@ public class MultipleOutputsWithConditionsServiceIntegrationTest {
@Test
public void whenSendMessage_thenResponseIsInAOutput() {
whenSendMessage(1);
thenPayloadInChannelIs(pipe.anOutput(), 1);
thenPayloadInChannelIs(pipe.anOutput(), "1");
}
@Test
public void whenSendMessage_thenResponseIsInAnotherOutput() {
whenSendMessage(11);
thenPayloadInChannelIs(pipe.anotherOutput(), 11);
thenPayloadInChannelIs(pipe.anotherOutput(), "11");
}
private void whenSendMessage(Integer val) {
@ -43,7 +43,7 @@ public class MultipleOutputsWithConditionsServiceIntegrationTest {
.build());
}
private void thenPayloadInChannelIs(MessageChannel channel, Integer expectedValue) {
private void thenPayloadInChannelIs(MessageChannel channel, String expectedValue) {
Object payload = messageCollector.forChannel(channel)
.poll()
.getPayload();

View File

@ -35,6 +35,6 @@ public class MyLoggerApplicationIntegrationTest {
.poll()
.getPayload();
assertEquals("[1]: This is my message", payload.toString());
assertEquals("{\"message\":\"[1]: This is my message\"}", payload.toString());
}
}

View File

@ -30,6 +30,10 @@
<artifactId>spring-boot-starter</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
@ -56,7 +60,10 @@
<artifactId>spring-cloud-starter-feign</artifactId>
<version>${spring-cloud-starter-feign.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
@ -71,7 +78,6 @@
</dependencies>
<properties>
<spring-cloud-starter-feign.version>1.2.5.RELEASE</spring-cloud-starter-feign.version>
<hamcrest-core.version>1.3</hamcrest-core.version>
</properties>

View File

@ -2,8 +2,8 @@ package com.baeldung.spring.cloud.greeting;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

View File

@ -18,8 +18,7 @@
</modules>
<properties>
<spring-boot.version>1.5.2.RELEASE</spring-boot.version>
<springframework.version>4.3.7.RELEASE</springframework.version>
<springframework.version>5.2.7.RELEASE</springframework.version>
<spring-cloud-starter-zookeeper-discovery.version>1.0.3.RELEASE</spring-cloud-starter-zookeeper-discovery.version>
</properties>