Skip to content

Commit

Permalink
增加服务发现中心和网关
Browse files Browse the repository at this point in the history
  • Loading branch information
beiyoufx committed Aug 10, 2018
1 parent f00a764 commit 0f78913
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 51 deletions.
25 changes: 1 addition & 24 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,6 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# project file
*.iml
*.ipr
Expand All @@ -53,4 +30,4 @@ hs_err_pid*
*.project
*.settings/*
/target/
*/target/*
*/target/*
18 changes: 6 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
<groupId>com.soraka</groupId>
<artifactId>soraka</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
<module>soraka-discovery</module>
<module>soraka-gateway</module>
</modules>

<developers>
<developer>
Expand All @@ -27,18 +33,6 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- 编译时的编码 -->
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
<fastjson.version>1.2.7</fastjson.version>
<spring.version>4.2.2.RELEASE</spring.version>
<mybatis.spring.version>1.2.4</mybatis.spring.version>
<mybatis.version>3.2.6</mybatis.version>
<dubbo.version>2.5.3</dubbo.version>
<junit.version>4.12</junit.version>
<log4j.version>1.2.17</log4j.version>
<slf4j.version>1.7.7</slf4j.version>
<xstream.version>1.4.4</xstream.version>
<druid.version>1.0.26</druid.version>
<mysql.connector.version>5.1.22</mysql.connector.version>
<jackson.version>2.9.0</jackson.version>
</properties>

<!--依赖-->
Expand Down
10 changes: 5 additions & 5 deletions soraka-eureka/pom.xml → soraka-discovery/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@
<modelVersion>4.0.0</modelVersion>

<groupId>com.soraka</groupId>
<artifactId>soraka-eureka</artifactId>
<artifactId>soraka-discovery</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>soraka-eureka</name>
<name>soraka-discovery</name>
<description>soraka注册中心</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<version>1.5.15.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<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>Finchley.SR1</spring-cloud.version>
<spring-cloud.version>Edgware.SR4</spring-cloud.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.soraka.eureka;
package com.soraka.discovery;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand All @@ -9,12 +9,12 @@
*
* @author yongjie.teng
* @date 2018/8/9
* @package com.soraka.eureka
* @package com.soraka.discovery
*/
@EnableEurekaServer
@SpringBootApplication
public class SorakaEurekaApplication {
public class SorakaDiscoveryApplication {
public static void main(String[] args) {
SpringApplication.run(SorakaEurekaApplication.class, args);
SpringApplication.run(SorakaDiscoveryApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
spring:
application:
name: soraka-eureka

name: soraka-discovery
server:
port: 8001

eureka:
instance:
hostname: localhost
Expand All @@ -13,4 +11,6 @@ eureka:
client:
registerWithEureka: false
fetchRegistry: false
service-url:
defaultZone: http://localhost:8001/eureka/

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.soraka.eureka;
package com.soraka.discovery;

import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -8,11 +8,11 @@
/**
* @author yongjie.teng
* @date 2018/8/9
* @package com.soraka.eureka
* @package com.soraka.discovery
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class SorakaEurekaApplicationTest {
public class SorakaDiscoveryApplicationTest {

@Test
public void contextLoads() {
Expand Down
67 changes: 67 additions & 0 deletions soraka-gateway/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?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.soraka</groupId>
<artifactId>soraka-gateway</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>soraka-gateway</name>
<description>soraka网关</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.15.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<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>Edgware.SR4</spring-cloud.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zuul</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>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.soraka.gateway;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;

/**
* Soraka网关
*
* @author yongjie.teng
* @date 2018/8/10
* @package com.soraka.gateway
*/
@EnableZuulProxy
@EnableEurekaClient
@SpringBootApplication
public class SorakaGatewayApplication {

public static void main(String[] args) {
SpringApplication.run(SorakaGatewayApplication.class, args);
}
}
21 changes: 21 additions & 0 deletions soraka-gateway/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
spring:
application:
name: soraka-gateway
server:
port: 8002
eureka:
instance:
hostname: localhost
prefer-ip-address: true
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://localhost:8001/eureka/
zuul:
ignored-services: '**'
routes:
soraka-weixin: 'mp/**'
management:
security:
enabled: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.soraka.gateway;

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 SorakaGatewayApplicationTests {

@Test
public void contextLoads() {
}

}

0 comments on commit 0f78913

Please sign in to comment.