Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
discovery
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢捷峰
discovery
Commits
b3387455
Commit
b3387455
authored
Jul 24, 2018
by
Nepxion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
上传Spring Cloud Api Gateway示例
parent
a9c43b6c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
187 additions
and
0 deletions
+187
-0
discovery-springcloud-example-gateway/pom.xml
+69
-0
discovery-springcloud-example-gateway/src/main/java/com/nepxion/discovery/plugin/example/DiscoveryApplicationGateway.java
+34
-0
discovery-springcloud-example-gateway/src/main/resources/application.properties
+34
-0
discovery-springcloud-example-gateway/src/main/resources/logback.xml
+49
-0
pom.xml
+1
-0
No files found.
discovery-springcloud-example-gateway/pom.xml
0 → 100644
View file @
b3387455
<?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"
>
<groupId>
com.nepxion
</groupId>
<artifactId>
discovery-springcloud-example-gateway
</artifactId>
<name>
Nepxion Discovery Spring Cloud Example Gateway
</name>
<packaging>
jar
</packaging>
<modelVersion>
4.0.0
</modelVersion>
<version>
1.0.0
</version>
<description>
Nepxion Discovery is an enhancement for Spring Cloud Discovery
</description>
<url>
http://www.nepxion.com
</url>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
2.0.3.RELEASE
</version>
</parent>
<properties>
<discovery.plugin.version>
4.1.2
</discovery.plugin.version>
<spring.cloud.version>
Finchley.RELEASE
</spring.cloud.version>
<java.version>
1.8
</java.version>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
</properties>
<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>
<dependencies>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-gateway
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-netflix-eureka-client
</artifactId>
<!-- <artifactId>spring-cloud-starter-consul-discovery</artifactId> -->
<!-- <artifactId>spring-cloud-starter-zookeeper-discovery</artifactId> -->
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<configuration>
<compilerArgs>
<arg>
-parameters
</arg>
</compilerArgs>
<encoding>
${project.build.sourceEncoding}
</encoding>
<source>
${java.version}
</source>
<target>
${java.version}
</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
discovery-springcloud-example-gateway/src/main/java/com/nepxion/discovery/plugin/example/DiscoveryApplicationGateway.java
0 → 100644
View file @
b3387455
package
com
.
nepxion
.
discovery
.
plugin
.
example
;
/**
* <p>Title: Nepxion Discovery</p>
* <p>Description: Nepxion Discovery</p>
* <p>Copyright: Copyright (c) 2017-2050</p>
* <p>Company: Nepxion</p>
* @author Haojun Ren
* @version 1.0
*/
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.gateway.route.RouteLocator
;
import
org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder
;
import
org.springframework.context.annotation.Bean
;
@SpringBootApplication
@EnableDiscoveryClient
public
class
DiscoveryApplicationGateway
{
public
static
void
main
(
String
[]
args
)
{
new
SpringApplicationBuilder
(
DiscoveryApplicationGateway
.
class
).
run
(
args
);
}
@Bean
public
RouteLocator
routeLocator
(
RouteLocatorBuilder
builder
)
{
return
builder
.
routes
()
.
route
(
r
->
r
.
path
(
"/**"
).
uri
(
"lb://DISCOVERY-SPRINGCLOUD-EXAMPLE-A"
).
id
(
"abc"
))
.
build
();
}
}
\ No newline at end of file
discovery-springcloud-example-gateway/src/main/resources/application.properties
0 → 100644
View file @
b3387455
# Spring cloud config
spring.application.name
=
discovery-springcloud-example-gateway
server.port
=
1500
# Eureka config
eureka.client.serviceUrl.defaultZone
=
http://localhost:9528/eureka/
eureka.instance.preferIpAddress
=
true
eureka.instance.metadataMap.version
=
1.0
eureka.instance.metadataMap.group
=
example-service-group
# Consul config
spring.cloud.consul.host
=
localhost
spring.cloud.consul.port
=
8500
spring.cloud.consul.discovery.preferIpAddress
=
true
spring.cloud.consul.discovery.tags
=
version=1.0,group=example-service-group
# Zookeeper config
spring.cloud.zookeeper.connectString
=
localhost:2181
spring.cloud.zookeeper.discovery.root
=
/spring-cloud-service
spring.cloud.zookeeper.discovery.preferIpAddress
=
true
spring.cloud.zookeeper.discovery.metadata.version
=
1.0
spring.cloud.zookeeper.discovery.metadata.group
=
example-service-group
# Ribbon config
ribbon.ReadTimeout
=
60000
ribbon.ConnectTimeout
=
60000
# Admin config
management.port
=
5500
management.security.enabled
=
false
spring.cloud.gateway.discovery.locator.enabled
=
true
logging.level.org.springframework.cloud.gateway
=
debug
\ No newline at end of file
discovery-springcloud-example-gateway/src/main/resources/logback.xml
0 → 100644
View file @
b3387455
<!-- Logback configuration. See http://logback.qos.ch/manual/index.html -->
<configuration
scan=
"true"
scanPeriod=
"10 seconds"
>
<!-- Simple file output -->
<appender
name=
"FILE"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<!-- encoder defaults to ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
<encoder>
<pattern>
discovery %date %level [%thread] %logger{10} [%file:%line] - %msg%n
</pattern>
<charset>
UTF-8
</charset>
</encoder>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"
>
<fileNamePattern>
log/discovery-%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<maxFileSize>
50MB
</maxFileSize>
</rollingPolicy>
<filter
class=
"ch.qos.logback.classic.filter.ThresholdFilter"
>
<level>
INFO
</level>
</filter>
<!-- Safely log to the same file from multiple JVMs. Degrades performance! -->
<prudent>
true
</prudent>
</appender>
<appender
name =
"FILE_ASYNC"
class=
"ch.qos.logback.classic.AsyncAppender"
>
<discardingThreshold>
0
</discardingThreshold>
<queueSize>
512
</queueSize>
<appender-ref
ref =
"FILE"
/>
</appender>
<!-- Console output -->
<appender
name=
"STDOUT"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<!-- encoder defaults to ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
<encoder>
<pattern>
discovery %date %level [%thread] %logger{10} [%file:%line] - %msg%n
</pattern>
<charset>
UTF-8
</charset>
</encoder>
<!-- Only log level WARN and above -->
<filter
class=
"ch.qos.logback.classic.filter.ThresholdFilter"
>
<level>
INFO
</level>
</filter>
</appender>
<!-- For loggers in the these namespaces, log at all levels. -->
<logger
name=
"pedestal"
level=
"ALL"
/>
<logger
name=
"hammock-cafe"
level=
"ALL"
/>
<logger
name=
"user"
level=
"ALL"
/>
<root
level=
"INFO"
>
<!-- <appender-ref ref="FILE_ASYNC" /> -->
<appender-ref
ref=
"STDOUT"
/>
</root>
</configuration>
pom.xml
View file @
b3387455
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
<module>
discovery-console-desktop
</module>
<module>
discovery-console-desktop
</module>
<module>
discovery-springcloud-example-console
</module>
<module>
discovery-springcloud-example-console
</module>
<module>
discovery-springcloud-example-eureka
</module>
<module>
discovery-springcloud-example-eureka
</module>
<module>
discovery-springcloud-example-gateway
</module>
<module>
discovery-springcloud-example
</module>
<module>
discovery-springcloud-example
</module>
</modules>
</modules>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment