Make spring-boot-starter-web truly optional.
Fixes gh-103
This commit is contained in:
@@ -22,6 +22,8 @@ Service Discovery is one of the key tenets of a microservice based architecture.
|
||||
|
||||
Including a dependency on `org.springframework.cloud:spring-cloud-starter-zookeeper-discovery` will enable auto-configuration that will setup Spring Cloud Zookeeper Discovery.
|
||||
|
||||
NOTE: You still need to include `org.springframework.boot:spring-boot-starter-web` for web functionality.
|
||||
|
||||
=== Registering with Zookeeper
|
||||
|
||||
When a client registers with Zookeeper, it provides meta-data about itself such as host and port, id and name.
|
||||
|
||||
@@ -57,9 +57,5 @@
|
||||
<groupId>com.netflix.ribbon</groupId>
|
||||
<artifactId>ribbon-loadbalancer</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
<main.basedir>${basedir}/../..</main.basedir>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-commons</artifactId>
|
||||
|
||||
@@ -40,6 +40,10 @@
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-zookeeper-all</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-actuator</artifactId>
|
||||
|
||||
@@ -12,5 +12,9 @@ endpoints:
|
||||
logging.level:
|
||||
org.apache.zookeeper.ClientCnxn: WARN
|
||||
|
||||
management:
|
||||
security:
|
||||
enabled: false
|
||||
|
||||
#spring.cloud.zookeeper.dependencies:
|
||||
# - testZookeeperApp: ~
|
||||
@@ -1,7 +1,3 @@
|
||||
spring:
|
||||
application:
|
||||
name: testZookeeperApp
|
||||
cloud:
|
||||
config:
|
||||
# TODO: refactor spring-cloud-config to use refresh, etc.. with out config client
|
||||
enabled: false
|
||||
|
||||
@@ -19,16 +19,28 @@ package org.springframework.cloud.zookeeper.sample;
|
||||
import org.apache.curator.test.TestingServer;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.SocketUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class SampleApplicationTests {
|
||||
|
||||
@Test public void contextLoads() throws Exception {
|
||||
int port = SocketUtils.findAvailableTcpPort();
|
||||
TestingServer server = new TestingServer(port);
|
||||
int zkPort = SocketUtils.findAvailableTcpPort();
|
||||
TestingServer server = new TestingServer(zkPort);
|
||||
|
||||
ConfigurableApplicationContext context = new SpringApplicationBuilder(SampleZookeeperApplication.class).run("--server.port=0", "--spring.cloud.zookeeper.connectString=localhost:" + port);
|
||||
int port = SocketUtils.findAvailableTcpPort(zkPort+1);
|
||||
|
||||
ConfigurableApplicationContext context = new SpringApplicationBuilder(SampleZookeeperApplication.class).run(
|
||||
"--server.port="+port,
|
||||
"--spring.cloud.zookeeper.connectString=localhost:" + zkPort);
|
||||
|
||||
ResponseEntity<String> response = new TestRestTemplate().getForEntity("http://localhost:"+port+"/health", String.class);
|
||||
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
|
||||
|
||||
context.close();
|
||||
server.close();
|
||||
|
||||
Reference in New Issue
Block a user