第二篇
This commit is contained in:
parent
b870ff1ae9
commit
d9d7bae339
@ -1,65 +1,65 @@
|
||||
<?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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.fxb</groupId>
|
||||
<artifactId>demo</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>confsvr</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.4.4.RELEASE</version>
|
||||
</parent>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>Camden.SR5</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<spring-cloud.version>Camden.SR5</spring-cloud.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-config-server</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-eureka</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
<?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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.fxb</groupId>
|
||||
<artifactId>demo</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>confsvr</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.4.4.RELEASE</version>
|
||||
</parent>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>Camden.SR5</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<spring-cloud.version>Camden.SR5</spring-cloud.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-config-server</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-eureka</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
|
@ -1,16 +1,16 @@
|
||||
package com.fxb.demo;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.config.server.EnableConfigServer;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableConfigServer
|
||||
@EnableDiscoveryClient
|
||||
public class ConfsvrApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ConfsvrApplication.class, args);
|
||||
}
|
||||
}
|
||||
package com.fxb.demo;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.config.server.EnableConfigServer;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableConfigServer
|
||||
@EnableDiscoveryClient
|
||||
public class ConfsvrApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ConfsvrApplication.class, args);
|
||||
}
|
||||
}
|
||||
|
@ -1,29 +1,29 @@
|
||||
server:
|
||||
port: 8888
|
||||
|
||||
eureka:
|
||||
instance:
|
||||
#注册服务的IP,而不是服务器名
|
||||
prefer-ip-address: true
|
||||
client:
|
||||
#向eureka注册服务
|
||||
register-with-eureka: true
|
||||
#拉取注册表的本地副本
|
||||
fetch-registry: true
|
||||
service-url:
|
||||
#Eureka服务的位置(如果有多个注册中心,使用,分隔)
|
||||
defaultZone: http://localhost:8761/eureka/
|
||||
|
||||
spring:
|
||||
profiles:
|
||||
# 使用文件系统来存储配置信息,需要设置为native
|
||||
active: native
|
||||
application:
|
||||
name: confsvr
|
||||
cloud:
|
||||
config:
|
||||
server:
|
||||
native:
|
||||
# 使用文件来存放配置文件,为每个应用程序提供用逗号分隔的文件夹列表
|
||||
searchLocations: file:///D:/configFolder/licensingservice,file:///D:/configFolder/organizationservice
|
||||
|
||||
server:
|
||||
port: 8888
|
||||
|
||||
eureka:
|
||||
instance:
|
||||
#注册服务的IP,而不是服务器名
|
||||
prefer-ip-address: true
|
||||
client:
|
||||
#向eureka注册服务
|
||||
register-with-eureka: true
|
||||
#拉取注册表的本地副本
|
||||
fetch-registry: true
|
||||
service-url:
|
||||
#Eureka服务的位置(如果有多个注册中心,使用,分隔)
|
||||
defaultZone: http://localhost:8761/eureka/
|
||||
|
||||
spring:
|
||||
profiles:
|
||||
# 使用文件系统来存储配置信息,需要设置为native
|
||||
active: native
|
||||
application:
|
||||
name: confsvr
|
||||
cloud:
|
||||
config:
|
||||
server:
|
||||
native:
|
||||
# 使用文件来存放配置文件,为每个应用程序提供用逗号分隔的文件夹列表
|
||||
searchLocations: file:///D:/configFolder/licensingservice,file:///D:/configFolder/organizationservice
|
||||
|
||||
|
@ -1,16 +1,16 @@
|
||||
package com.fxb.demo;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class ConfsvrApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
package com.fxb.demo;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class ConfsvrApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,72 +1,72 @@
|
||||
<?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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.fxb</groupId>
|
||||
<artifactId>eurekasvr</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>eurekasvr</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.4.4.RELEASE</version>
|
||||
</parent>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>Camden.SR5</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<spring-cloud.version>Camden.SR5</spring-cloud.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-eureka-server</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
||||
</project>
|
||||
<?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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.fxb</groupId>
|
||||
<artifactId>eurekasvr</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>eurekasvr</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.4.4.RELEASE</version>
|
||||
</parent>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>Camden.SR5</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<spring-cloud.version>Camden.SR5</spring-cloud.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-eureka-server</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
||||
</project>
|
||||
|
@ -1,14 +1,14 @@
|
||||
package com.fxb.eurekasvr;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableEurekaServer
|
||||
public class EurekasvrApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(EurekasvrApplication.class, args);
|
||||
}
|
||||
}
|
||||
package com.fxb.eurekasvr;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableEurekaServer
|
||||
public class EurekasvrApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(EurekasvrApplication.class, args);
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
server:
|
||||
port: 8761
|
||||
|
||||
eureka:
|
||||
client:
|
||||
#不注册自己
|
||||
register-with-eureka: false
|
||||
#不在本地缓存注册表信息
|
||||
fetch-registry: false
|
||||
server:
|
||||
#接受请求前的等待实际,开发模式下不要开启
|
||||
#wait-time-in-ms-when-sync-empty: 5
|
||||
server:
|
||||
port: 8761
|
||||
|
||||
eureka:
|
||||
client:
|
||||
#不注册自己
|
||||
register-with-eureka: false
|
||||
#不在本地缓存注册表信息
|
||||
fetch-registry: false
|
||||
server:
|
||||
#接受请求前的等待实际,开发模式下不要开启
|
||||
#wait-time-in-ms-when-sync-empty: 5
|
||||
|
@ -1,16 +1,16 @@
|
||||
package com.fxb.eurekasvr;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class EurekasvrApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
package com.fxb.eurekasvr;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class EurekasvrApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,69 +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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.fxb</groupId>
|
||||
<artifactId>licensingservice</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>licensingservice</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.4.4.RELEASE</version>
|
||||
</parent>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>Camden.SR5</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<spring-cloud.version>Camden.SR5</spring-cloud.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-eureka</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-config-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-feign</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
<?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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.fxb</groupId>
|
||||
<artifactId>licensingservice</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>licensingservice</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.4.4.RELEASE</version>
|
||||
</parent>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>Camden.SR5</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<spring-cloud.version>Camden.SR5</spring-cloud.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-eureka</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-config-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-feign</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
|
@ -1,31 +1,31 @@
|
||||
package com.fxb.licensingservice.Entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 类功能简述:
|
||||
* 类功能详述:
|
||||
*
|
||||
* @author fanxb
|
||||
* @date 2018/11/22 19:52
|
||||
*/
|
||||
public class Licensing implements Serializable {
|
||||
private Organization organization;
|
||||
private boolean isValid;
|
||||
|
||||
public Organization getOrganization() {
|
||||
return organization;
|
||||
}
|
||||
|
||||
public void setOrganization(Organization organization) {
|
||||
this.organization = organization;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return isValid;
|
||||
}
|
||||
|
||||
public void setValid(boolean valid) {
|
||||
isValid = valid;
|
||||
}
|
||||
}
|
||||
package com.fxb.licensingservice.Entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 类功能简述:
|
||||
* 类功能详述:
|
||||
*
|
||||
* @author fanxb
|
||||
* @date 2018/11/22 19:52
|
||||
*/
|
||||
public class Licensing implements Serializable {
|
||||
private Organization organization;
|
||||
private boolean isValid;
|
||||
|
||||
public Organization getOrganization() {
|
||||
return organization;
|
||||
}
|
||||
|
||||
public void setOrganization(Organization organization) {
|
||||
this.organization = organization;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return isValid;
|
||||
}
|
||||
|
||||
public void setValid(boolean valid) {
|
||||
isValid = valid;
|
||||
}
|
||||
}
|
||||
|
@ -1,40 +1,40 @@
|
||||
package com.fxb.licensingservice.Entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 类功能简述:
|
||||
* 类功能详述:
|
||||
*
|
||||
* @author fanxb
|
||||
* @date 2018/11/22 19:30
|
||||
*/
|
||||
public class Organization implements Serializable {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
|
||||
public Organization() {
|
||||
}
|
||||
|
||||
public Organization(String id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
package com.fxb.licensingservice.Entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 类功能简述:
|
||||
* 类功能详述:
|
||||
*
|
||||
* @author fanxb
|
||||
* @date 2018/11/22 19:30
|
||||
*/
|
||||
public class Organization implements Serializable {
|
||||
|
||||
private String id;
|
||||
private String name;
|
||||
|
||||
public Organization() {
|
||||
}
|
||||
|
||||
public Organization(String id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
@ -1,28 +1,28 @@
|
||||
package com.fxb.licensingservice;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
|
||||
import org.springframework.cloud.netflix.feign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient //使用不带Ribbon功能的Spring RestTemplate,其他情况下可删除
|
||||
@EnableFeignClients //使用Feign客户端进行服务调用,其他情况下可删除
|
||||
public class LicensingserviceApplication {
|
||||
|
||||
/**
|
||||
* 使用带有Ribbon 功能的Spring RestTemplate,其他情况可删除
|
||||
*/
|
||||
@LoadBalanced
|
||||
@Bean
|
||||
public RestTemplate getRestTemplate(){
|
||||
return new RestTemplate();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(LicensingserviceApplication.class, args);
|
||||
}
|
||||
}
|
||||
package com.fxb.licensingservice;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
|
||||
import org.springframework.cloud.netflix.feign.EnableFeignClients;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient //使用不带Ribbon功能的Spring RestTemplate,其他情况下可删除
|
||||
@EnableFeignClients //使用Feign客户端进行服务调用,其他情况下可删除
|
||||
public class LicensingserviceApplication {
|
||||
|
||||
/**
|
||||
* 使用带有Ribbon 功能的Spring RestTemplate,其他情况可删除
|
||||
*/
|
||||
@LoadBalanced
|
||||
@Bean
|
||||
public RestTemplate getRestTemplate(){
|
||||
return new RestTemplate();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(LicensingserviceApplication.class, args);
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +1,27 @@
|
||||
package com.fxb.licensingservice.client;
|
||||
|
||||
import com.fxb.licensingservice.Entity.Organization;
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
/**
|
||||
* 类功能简述:
|
||||
* 类功能详述:
|
||||
*
|
||||
* @author fanxb
|
||||
* @date 2018/11/23 17:24
|
||||
*/
|
||||
@FeignClient("organizationservice")//使用FeignClient注解指定目标服务
|
||||
public interface OrganizationFeignClient {
|
||||
|
||||
/**
|
||||
* 获取组织信息
|
||||
*
|
||||
* @param orgId 组织id
|
||||
* @return Organization
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/organization/{orgId}", consumes = "application/json")
|
||||
Organization getOrganization(@PathVariable("orgId") String orgId);
|
||||
}
|
||||
package com.fxb.licensingservice.client;
|
||||
|
||||
import com.fxb.licensingservice.Entity.Organization;
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
/**
|
||||
* 类功能简述:
|
||||
* 类功能详述:
|
||||
*
|
||||
* @author fanxb
|
||||
* @date 2018/11/23 17:24
|
||||
*/
|
||||
@FeignClient("organizationservice")//使用FeignClient注解指定目标服务
|
||||
public interface OrganizationFeignClient {
|
||||
|
||||
/**
|
||||
* 获取组织信息
|
||||
*
|
||||
* @param orgId 组织id
|
||||
* @return Organization
|
||||
*/
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/organization/{orgId}", consumes = "application/json")
|
||||
Organization getOrganization(@PathVariable("orgId") String orgId);
|
||||
}
|
||||
|
@ -1,56 +1,56 @@
|
||||
package com.fxb.licensingservice.controller;
|
||||
|
||||
import com.fxb.licensingservice.Entity.Licensing;
|
||||
import com.fxb.licensingservice.client.OrganizationFeignClient;
|
||||
import com.fxb.licensingservice.service.OrganizationByRibbonService;
|
||||
import com.fxb.licensingservice.service.OrganizationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 类功能简述:
|
||||
* 类功能详述:
|
||||
*
|
||||
* @author fanxb
|
||||
* @date 2018/11/22 19:51
|
||||
*/
|
||||
@RestController
|
||||
public class LicensingController {
|
||||
|
||||
private OrganizationService organizationService;
|
||||
private OrganizationByRibbonService ribbonService;
|
||||
private OrganizationFeignClient organizationFeignClient;
|
||||
|
||||
@Autowired
|
||||
public LicensingController(OrganizationService organizationService, OrganizationByRibbonService ribbonService, OrganizationFeignClient feignClient) {
|
||||
this.organizationService = organizationService;
|
||||
this.ribbonService = ribbonService;
|
||||
this.organizationFeignClient = feignClient;
|
||||
}
|
||||
|
||||
@GetMapping("/licensing/{orgId}")
|
||||
public Licensing getLicensing(@PathVariable("orgId") String orgId) {
|
||||
Licensing licensing = new Licensing();
|
||||
licensing.setValid(false);
|
||||
licensing.setOrganization(organizationService.getOrganization(orgId));
|
||||
return licensing;
|
||||
}
|
||||
|
||||
@GetMapping("/licensingByRibbon/{orgId}")
|
||||
public Licensing getLicensingByRibbon(@PathVariable("orgId") String orgId) {
|
||||
Licensing licensing = new Licensing();
|
||||
licensing.setValid(false);
|
||||
licensing.setOrganization(ribbonService.getOrganizationWithRibbon(orgId));
|
||||
return licensing;
|
||||
}
|
||||
|
||||
@GetMapping("/licensingByFeign/{orgId}")
|
||||
public Licensing getLicensingByFeign(@PathVariable("orgId") String orgId) {
|
||||
Licensing licensing = new Licensing();
|
||||
licensing.setValid(false);
|
||||
licensing.setOrganization(organizationFeignClient.getOrganization(orgId));
|
||||
return licensing;
|
||||
}
|
||||
}
|
||||
package com.fxb.licensingservice.controller;
|
||||
|
||||
import com.fxb.licensingservice.Entity.Licensing;
|
||||
import com.fxb.licensingservice.client.OrganizationFeignClient;
|
||||
import com.fxb.licensingservice.service.OrganizationByRibbonService;
|
||||
import com.fxb.licensingservice.service.OrganizationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 类功能简述:
|
||||
* 类功能详述:
|
||||
*
|
||||
* @author fanxb
|
||||
* @date 2018/11/22 19:51
|
||||
*/
|
||||
@RestController
|
||||
public class LicensingController {
|
||||
|
||||
private OrganizationService organizationService;
|
||||
private OrganizationByRibbonService ribbonService;
|
||||
private OrganizationFeignClient organizationFeignClient;
|
||||
|
||||
@Autowired
|
||||
public LicensingController(OrganizationService organizationService, OrganizationByRibbonService ribbonService, OrganizationFeignClient feignClient) {
|
||||
this.organizationService = organizationService;
|
||||
this.ribbonService = ribbonService;
|
||||
this.organizationFeignClient = feignClient;
|
||||
}
|
||||
|
||||
@GetMapping("/licensing/{orgId}")
|
||||
public Licensing getLicensing(@PathVariable("orgId") String orgId) {
|
||||
Licensing licensing = new Licensing();
|
||||
licensing.setValid(false);
|
||||
licensing.setOrganization(organizationService.getOrganization(orgId));
|
||||
return licensing;
|
||||
}
|
||||
|
||||
@GetMapping("/licensingByRibbon/{orgId}")
|
||||
public Licensing getLicensingByRibbon(@PathVariable("orgId") String orgId) {
|
||||
Licensing licensing = new Licensing();
|
||||
licensing.setValid(false);
|
||||
licensing.setOrganization(ribbonService.getOrganizationWithRibbon(orgId));
|
||||
return licensing;
|
||||
}
|
||||
|
||||
@GetMapping("/licensingByFeign/{orgId}")
|
||||
public Licensing getLicensingByFeign(@PathVariable("orgId") String orgId) {
|
||||
Licensing licensing = new Licensing();
|
||||
licensing.setValid(false);
|
||||
licensing.setOrganization(organizationFeignClient.getOrganization(orgId));
|
||||
return licensing;
|
||||
}
|
||||
}
|
||||
|
@ -1,32 +1,32 @@
|
||||
package com.fxb.licensingservice.service;
|
||||
|
||||
import com.fxb.licensingservice.Entity.Organization;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
* 类功能简述:
|
||||
* 类功能详述:
|
||||
*
|
||||
* @author fanxb
|
||||
* @date 2018/11/23 15:36
|
||||
*/
|
||||
@Component
|
||||
public class OrganizationByRibbonService {
|
||||
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
@Autowired
|
||||
public OrganizationByRibbonService(RestTemplate restTemplate) {
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
public Organization getOrganizationWithRibbon(String id) {
|
||||
ResponseEntity<Organization> responseEntity = restTemplate.exchange("http://organizationservice/organization/{id}",
|
||||
HttpMethod.GET, null, Organization.class, id);
|
||||
return responseEntity.getBody();
|
||||
}
|
||||
}
|
||||
package com.fxb.licensingservice.service;
|
||||
|
||||
import com.fxb.licensingservice.Entity.Organization;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
* 类功能简述:
|
||||
* 类功能详述:
|
||||
*
|
||||
* @author fanxb
|
||||
* @date 2018/11/23 15:36
|
||||
*/
|
||||
@Component
|
||||
public class OrganizationByRibbonService {
|
||||
|
||||
private RestTemplate restTemplate;
|
||||
|
||||
@Autowired
|
||||
public OrganizationByRibbonService(RestTemplate restTemplate) {
|
||||
this.restTemplate = restTemplate;
|
||||
}
|
||||
|
||||
public Organization getOrganizationWithRibbon(String id) {
|
||||
ResponseEntity<Organization> responseEntity = restTemplate.exchange("http://organizationservice/organization/{id}",
|
||||
HttpMethod.GET, null, Organization.class, id);
|
||||
return responseEntity.getBody();
|
||||
}
|
||||
}
|
||||
|
@ -1,50 +1,50 @@
|
||||
package com.fxb.licensingservice.service;
|
||||
|
||||
import com.fxb.licensingservice.Entity.Organization;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类功能简述:
|
||||
* 类功能详述:
|
||||
*
|
||||
* @author fanxb
|
||||
* @date 2018/11/22 19:29
|
||||
*/
|
||||
@Service
|
||||
public class OrganizationService {
|
||||
|
||||
private static final String SERVICE_NAME = "organizationservice";
|
||||
private DiscoveryClient discoveryClient;
|
||||
|
||||
@Autowired
|
||||
public OrganizationService(DiscoveryClient discoveryClient) {
|
||||
this.discoveryClient = discoveryClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用Spring DiscoveryClient查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public Organization getOrganization(String id) {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
List<ServiceInstance> instances = discoveryClient.getInstances(SERVICE_NAME);
|
||||
if (instances.size() == 0) {
|
||||
throw new RuntimeException("无可用的服务");
|
||||
}
|
||||
String serviceUri = String.format("%s/organization/%s", instances.get(0).getUri().toString(), id);
|
||||
ResponseEntity<Organization> responseEntity = restTemplate.exchange(serviceUri, HttpMethod.GET
|
||||
, null, Organization.class, id);
|
||||
return responseEntity.getBody();
|
||||
}
|
||||
|
||||
}
|
||||
package com.fxb.licensingservice.service;
|
||||
|
||||
import com.fxb.licensingservice.Entity.Organization;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类功能简述:
|
||||
* 类功能详述:
|
||||
*
|
||||
* @author fanxb
|
||||
* @date 2018/11/22 19:29
|
||||
*/
|
||||
@Service
|
||||
public class OrganizationService {
|
||||
|
||||
private static final String SERVICE_NAME = "organizationservice";
|
||||
private DiscoveryClient discoveryClient;
|
||||
|
||||
@Autowired
|
||||
public OrganizationService(DiscoveryClient discoveryClient) {
|
||||
this.discoveryClient = discoveryClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用Spring DiscoveryClient查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public Organization getOrganization(String id) {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
List<ServiceInstance> instances = discoveryClient.getInstances(SERVICE_NAME);
|
||||
if (instances.size() == 0) {
|
||||
throw new RuntimeException("无可用的服务");
|
||||
}
|
||||
String serviceUri = String.format("%s/organization/%s", instances.get(0).getUri().toString(), id);
|
||||
ResponseEntity<Organization> responseEntity = restTemplate.exchange(serviceUri, HttpMethod.GET
|
||||
, null, Organization.class, id);
|
||||
return responseEntity.getBody();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,19 +1,19 @@
|
||||
spring:
|
||||
application:
|
||||
#指定名称,以便spring cloud config客户端知道查找哪个配置
|
||||
name: licensingservice
|
||||
profiles:
|
||||
#指定环境
|
||||
active: dev
|
||||
cloud:
|
||||
config:
|
||||
enabled: true
|
||||
eureka:
|
||||
instance:
|
||||
prefer-ip-address: true
|
||||
client:
|
||||
register-with-eureka: true
|
||||
fetch-registry: true
|
||||
service-url:
|
||||
defaultZone: http://localhost:8761/eureka/
|
||||
|
||||
spring:
|
||||
application:
|
||||
#指定名称,以便spring cloud config客户端知道查找哪个配置
|
||||
name: licensingservice
|
||||
profiles:
|
||||
#指定环境
|
||||
active: dev
|
||||
cloud:
|
||||
config:
|
||||
enabled: true
|
||||
eureka:
|
||||
instance:
|
||||
prefer-ip-address: true
|
||||
client:
|
||||
register-with-eureka: true
|
||||
fetch-registry: true
|
||||
service-url:
|
||||
defaultZone: http://localhost:8761/eureka/
|
||||
|
||||
|
@ -1,16 +1,16 @@
|
||||
package com.fxb.licensingservice;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class LicensingserviceApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
package com.fxb.licensingservice;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class LicensingserviceApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,65 +1,65 @@
|
||||
<?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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.fxb</groupId>
|
||||
<artifactId>organizationservice</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>organizationservice</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.4.4.RELEASE</version>
|
||||
</parent>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>Camden.SR5</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<spring-cloud.version>Camden.SR5</spring-cloud.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-eureka</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-config-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
<?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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.fxb</groupId>
|
||||
<artifactId>organizationservice</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>organizationservice</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>1.4.4.RELEASE</version>
|
||||
</parent>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>Camden.SR5</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<spring-cloud.version>Camden.SR5</spring-cloud.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-eureka</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-config-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
|
@ -1,14 +1,14 @@
|
||||
package com.fxb.organizationservice;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
public class OrganizationserviceApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(OrganizationserviceApplication.class, args);
|
||||
}
|
||||
}
|
||||
package com.fxb.organizationservice;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableDiscoveryClient
|
||||
public class OrganizationserviceApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(OrganizationserviceApplication.class, args);
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +1,27 @@
|
||||
package com.fxb.organizationservice.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 类功能简述:
|
||||
* 类功能详述:
|
||||
*
|
||||
* @author fanxb
|
||||
* @date 2018/11/22 18:23
|
||||
*/
|
||||
@RestController
|
||||
public class OrganizationController {
|
||||
|
||||
@GetMapping(value = "/organization/{orgId}")
|
||||
public Object getOrganizationInfo(@PathVariable("orgId") String orgId) {
|
||||
Map<String, String> data = new HashMap<>(2);
|
||||
data.put("id", orgId);
|
||||
data.put("name", orgId + "公司");
|
||||
return data;
|
||||
}
|
||||
}
|
||||
package com.fxb.organizationservice.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 类功能简述:
|
||||
* 类功能详述:
|
||||
*
|
||||
* @author fanxb
|
||||
* @date 2018/11/22 18:23
|
||||
*/
|
||||
@RestController
|
||||
public class OrganizationController {
|
||||
|
||||
@GetMapping(value = "/organization/{orgId}")
|
||||
public Object getOrganizationInfo(@PathVariable("orgId") String orgId) {
|
||||
Map<String, String> data = new HashMap<>(2);
|
||||
data.put("id", orgId);
|
||||
data.put("name", orgId + "公司");
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,18 @@
|
||||
spring:
|
||||
application:
|
||||
#指定名称,以便spring cloud config客户端知道查找哪个配置
|
||||
name: organizationservice
|
||||
profiles:
|
||||
#指定环境
|
||||
active: dev
|
||||
cloud:
|
||||
config:
|
||||
enabled: true
|
||||
eureka:
|
||||
instance:
|
||||
prefer-ip-address: true
|
||||
client:
|
||||
register-with-eureka: true
|
||||
fetch-registry: true
|
||||
service-url:
|
||||
spring:
|
||||
application:
|
||||
#指定名称,以便spring cloud config客户端知道查找哪个配置
|
||||
name: organizationservice
|
||||
profiles:
|
||||
#指定环境
|
||||
active: dev
|
||||
cloud:
|
||||
config:
|
||||
enabled: true
|
||||
eureka:
|
||||
instance:
|
||||
prefer-ip-address: true
|
||||
client:
|
||||
register-with-eureka: true
|
||||
fetch-registry: true
|
||||
service-url:
|
||||
defaultZone: http://localhost:8761/eureka/
|
@ -1,16 +1,16 @@
|
||||
package com.fxb.organizationservice;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class OrganizationserviceApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
package com.fxb.organizationservice;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest
|
||||
public class OrganizationserviceApplicationTests {
|
||||
|
||||
@Test
|
||||
public void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user