├── spring-cloud-zuul
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── jwt.jks
│ │ │ ├── logback.xml
│ │ │ ├── user.sql
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── chengbinbbs
│ │ │ ├── service
│ │ │ └── UserService.java
│ │ │ ├── entity
│ │ │ └── UserEntity.java
│ │ │ ├── SpringCloudZuulApplication.java
│ │ │ ├── filter
│ │ │ ├── AfterCsrfFilter.java
│ │ │ ├── BeforeLoginFilter.java
│ │ │ └── AccessFilter.java
│ │ │ ├── controller
│ │ │ └── UserController.java
│ │ │ ├── oauth
│ │ │ ├── db
│ │ │ │ ├── AnyUserDetailsService.java
│ │ │ │ └── WebSecurityConfig.java
│ │ │ └── WebSecurityConfig.java
│ │ │ └── distribute
│ │ │ ├── queue
│ │ │ └── DistributedBlockingQueue.java
│ │ │ └── locks
│ │ │ └── DistributedLock.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── chengbinbbs
│ │ ├── SpringCloudZuulApplicationTests.java
│ │ ├── DistributedBolckingQueueTest.java
│ │ └── DistributedLockTest.java
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── .gitignore
├── pom.xml
├── mvnw.cmd
└── mvnw
├── spring-cloud-admin
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── logback.xml
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── chengbinbbs
│ │ │ └── SpringCloudAdminApplication.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── chengbinbbs
│ │ └── SpringCloudAdminApplicationTests.java
├── .gitignore
├── pom.xml
├── mvnw.cmd
└── mvnw
├── spring-cloud-feign
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── logback.xml
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── chengbinbbs
│ │ │ ├── SpringCloudFeignApplication.java
│ │ │ ├── fallback
│ │ │ └── UserClientHystrix.java
│ │ │ ├── service
│ │ │ └── UserClient.java
│ │ │ ├── controller
│ │ │ └── UserController.java
│ │ │ └── module
│ │ │ └── User.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── chengbinbbs
│ │ └── SpringCloudFeignApplicationTests.java
├── .gitignore
├── pom.xml
├── mvnw.cmd
└── mvnw
├── spring-cloud-config
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── logback.xml
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── chengbinbbs
│ │ │ └── SpringCloudConfigApplication.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── chengbinbbs
│ │ └── SpringCloudConfigApplicationTests.java
├── .gitignore
├── pom.xml
├── mvnw.cmd
└── mvnw
├── spring-cloud-eureka
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── logback.xml
│ │ │ ├── application-peer1.properties
│ │ │ ├── application-peer2.properties
│ │ │ ├── application-peer3.properties
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── chengbinbbs
│ │ │ └── SpringCloudEurekaApplication.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── chengbinbbs
│ │ └── SpringCloudEurekaApplicationTests.java
├── .gitignore
├── pom.xml
├── mvnw.cmd
└── mvnw
├── spring-cloud-ribbon
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── logback.xml
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── chengbinbbs
│ │ │ ├── SpringCloudRibbonApplication.java
│ │ │ ├── module
│ │ │ └── User.java
│ │ │ ├── controller
│ │ │ └── UserController.java
│ │ │ └── service
│ │ │ └── UserService.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── chengbinbbs
│ │ └── SpringCloudRibbonApplicationTests.java
├── .gitignore
├── pom.xml
├── mvnw.cmd
└── mvnw
├── spring-cloud-turbine
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── logback.xml
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── chengbinbbs
│ │ │ └── SpringCloudTurbineApplication.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── chengbinbbs
│ │ └── SpringCloudTurbineApplicationTests.java
├── .gitignore
├── pom.xml
└── mvnw.cmd
├── README.md
├── spring-cloud-hystrixDashboard
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── application.properties
│ │ │ └── logback.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── chengbinbbs
│ │ │ └── SpringCloudHystrixdashboardApplication.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── chengbinbbs
│ │ └── SpringCloudHystrixdashboardApplicationTests.java
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── .gitignore
├── pom.xml
└── mvnw.cmd
├── spring-cloud-userservice
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── logback.xml
│ │ │ └── application.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── chengbinbbs
│ │ │ ├── module
│ │ │ └── User.java
│ │ │ ├── SpringCloudUserserviceApplication.java
│ │ │ ├── aop
│ │ │ └── ServiceMonitor.java
│ │ │ └── controller
│ │ │ └── UserController.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── chengbinbbs
│ │ └── SpringCloudUserserviceApplicationTests.java
├── .gitignore
├── pom.xml
└── mvnw.cmd
├── spring-cloud-config-client
├── .mvn
│ └── wrapper
│ │ ├── maven-wrapper.jar
│ │ └── maven-wrapper.properties
├── src
│ ├── main
│ │ ├── resources
│ │ │ ├── logback.xml
│ │ │ └── bootstrap.properties
│ │ └── java
│ │ │ └── com
│ │ │ └── chengbinbbs
│ │ │ ├── SpringCloudConfigClientApplication.java
│ │ │ └── controller
│ │ │ └── TestController.java
│ └── test
│ │ └── java
│ │ └── com
│ │ └── chengbinbbs
│ │ └── SpringCloudConfigClientApplicationTests.java
├── .gitignore
├── pom.xml
└── mvnw.cmd
├── springcloudconfigconsumer.iml
├── .gitattributes
├── .gitignore
├── pom.xml
└── spring-cloud.iml
/spring-cloud-zuul/src/main/resources/jwt.jks:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/spring-cloud-admin/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chengbinbbs/spring-cloud/HEAD/spring-cloud-admin/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/spring-cloud-feign/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chengbinbbs/spring-cloud/HEAD/spring-cloud-feign/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/spring-cloud-zuul/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chengbinbbs/spring-cloud/HEAD/spring-cloud-zuul/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/spring-cloud-config/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chengbinbbs/spring-cloud/HEAD/spring-cloud-config/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/spring-cloud-eureka/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chengbinbbs/spring-cloud/HEAD/spring-cloud-eureka/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/spring-cloud-ribbon/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chengbinbbs/spring-cloud/HEAD/spring-cloud-ribbon/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/spring-cloud-turbine/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chengbinbbs/spring-cloud/HEAD/spring-cloud-turbine/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # spring-cloud
2 | SpringCloud微服务架构,提供快速上手脚手架,快速构建高可用注册中心,高可用配置中心,加入Hystrix断路器,gateway服务网关,权限认证、服务降级、限流,加入应用监控。
3 |
4 | 如您觉得该项目对您有用,欢迎点击右上方的Star按钮,给予支持,谢谢!!
5 |
--------------------------------------------------------------------------------
/spring-cloud-admin/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/spring-cloud-config/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/spring-cloud-eureka/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/spring-cloud-feign/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/spring-cloud-hystrixDashboard/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=hystrixdashboard
2 | server.port=9999
3 |
4 | info.version=0.0.1-SNAPSHOT
--------------------------------------------------------------------------------
/spring-cloud-ribbon/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/spring-cloud-turbine/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/spring-cloud-userservice/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chengbinbbs/spring-cloud/HEAD/spring-cloud-userservice/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/spring-cloud-zuul/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/spring-cloud-config-client/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chengbinbbs/spring-cloud/HEAD/spring-cloud-config-client/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/spring-cloud-config-client/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/spring-cloud-userservice/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/spring-cloud-hystrixDashboard/.mvn/wrapper/maven-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/chengbinbbs/spring-cloud/HEAD/spring-cloud-hystrixDashboard/.mvn/wrapper/maven-wrapper.jar
--------------------------------------------------------------------------------
/spring-cloud-hystrixDashboard/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.0/apache-maven-3.5.0-bin.zip
2 |
--------------------------------------------------------------------------------
/spring-cloud-admin/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/spring-cloud-config/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/spring-cloud-eureka/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/spring-cloud-feign/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/spring-cloud-ribbon/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/spring-cloud-zuul/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/spring-cloud-turbine/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/spring-cloud-userservice/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/spring-cloud-config-client/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/spring-cloud-hystrixDashboard/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/springcloudconfigconsumer.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/spring-cloud-feign/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=feign-consumer
2 | server.port=4444
3 | eureka.client.serviceUrl.defaultZone=http://peer1:1111/eureka/,http://peer2:1112/eureka/,http://peer3:1113/eureka/
4 |
5 | info.version=0.0.1-SNAPSHOT
--------------------------------------------------------------------------------
/spring-cloud-zuul/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/spring-cloud-admin/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/spring-cloud-config/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/spring-cloud-eureka/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/spring-cloud-feign/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/spring-cloud-ribbon/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/spring-cloud-turbine/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/spring-cloud-config-client/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/spring-cloud-userservice/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/spring-cloud-hystrixDashboard/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | !.mvn/wrapper/maven-wrapper.jar
3 |
4 | ### STS ###
5 | .apt_generated
6 | .classpath
7 | .factorypath
8 | .project
9 | .settings
10 | .springBeans
11 |
12 | ### IntelliJ IDEA ###
13 | .idea
14 | *.iws
15 | *.iml
16 | *.ipr
17 |
18 | ### NetBeans ###
19 | nbproject/private/
20 | build/
21 | nbbuild/
22 | dist/
23 | nbdist/
24 | .nb-gradle/
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/spring-cloud-eureka/src/main/resources/application-peer1.properties:
--------------------------------------------------------------------------------
1 | server.port=1111
2 | spring.application.name=eureka.server
3 | eureka.instance.hostname=peer1
4 |
5 | security.basic.enabled=true
6 | security.user.name=root
7 | security.user.password=123456
8 |
9 | #eureka.client.register-with-eureka=false
10 | #eureka.client.fetch-registry=false
11 | eureka.client.serviceUrl.defaultZone=http://root:123456@peer2:1112/eureka/,http://root:123456@peer3:1113/eureka/
12 |
--------------------------------------------------------------------------------
/spring-cloud-eureka/src/main/resources/application-peer2.properties:
--------------------------------------------------------------------------------
1 | server.port=1112
2 | spring.application.name=eureka.server
3 | eureka.instance.hostname=peer2
4 |
5 | security.basic.enabled=true
6 | security.user.name=root
7 | security.user.password=123456
8 |
9 | #eureka.client.register-with-eureka=false
10 | #eureka.client.fetch-registry=false
11 | eureka.client.serviceUrl.defaultZone=http://root:123456@peer1:1111/eureka/,http://root:123456@peer3:1113/eureka/
12 |
--------------------------------------------------------------------------------
/spring-cloud-eureka/src/main/resources/application-peer3.properties:
--------------------------------------------------------------------------------
1 | server.port=1113
2 | spring.application.name=eureka.server
3 | eureka.instance.hostname=peer3
4 |
5 | security.basic.enabled=true
6 | security.user.name=root
7 | security.user.password=123456
8 |
9 | #eureka.client.register-with-eureka=false
10 | #eureka.client.fetch-registry=false
11 | eureka.client.serviceUrl.defaultZone=http://root:123456@peer2:1112/eureka/,http://root:123456@peer1:1111/eureka/
12 |
--------------------------------------------------------------------------------
/spring-cloud-turbine/src/main/java/com/chengbinbbs/SpringCloudTurbineApplication.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.turbine.EnableTurbine;
6 |
7 | @EnableTurbine
8 | @SpringBootApplication
9 | public class SpringCloudTurbineApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(SpringCloudTurbineApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/spring-cloud-userservice/src/main/java/com/chengbinbbs/module/User.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs.module;
2 |
3 | import lombok.Data;
4 |
5 | import java.io.Serializable;
6 |
7 | /**
8 | * 用户实体类
9 | *
10 | * @author zhangcb
11 | * @created 2017-05-24 11:47.
12 | */
13 | @Data
14 | public class User implements Serializable {
15 |
16 | private Long id;
17 |
18 | private String name;
19 |
20 | private Integer age;
21 |
22 | public User(String name, Integer age) {
23 | this.name = name;
24 | this.age = age;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/spring-cloud-config-client/src/main/java/com/chengbinbbs/SpringCloudConfigClientApplication.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
6 |
7 | @EnableEurekaClient
8 | @SpringBootApplication
9 | public class SpringCloudConfigClientApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(SpringCloudConfigClientApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/spring-cloud-zuul/src/test/java/com/chengbinbbs/SpringCloudZuulApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = SpringCloudZuulApplication.class)
10 | public class SpringCloudZuulApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/spring-cloud-admin/src/test/java/com/chengbinbbs/SpringCloudAdminApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = SpringCloudAdminApplication.class)
10 | public class SpringCloudAdminApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/spring-cloud-feign/src/test/java/com/chengbinbbs/SpringCloudFeignApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = SpringCloudFeignApplication.class)
10 | public class SpringCloudFeignApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/spring-cloud-zuul/src/main/java/com/chengbinbbs/service/UserService.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs.service;
2 |
3 | import com.chengbinbbs.entity.UserEntity;
4 |
5 | /**
6 | * @author zhangcb
7 | * @created on 2017/6/15.
8 | */
9 | public interface UserService {
10 |
11 | /**
12 | * 添加新用户
13 | *
14 | * username 唯一, 默认 USER 权限
15 | */
16 | boolean insert(UserEntity userEntity);
17 |
18 | /**
19 | * 查询用户信息
20 | * @param username 账号
21 | * @return UserEntity
22 | */
23 | UserEntity getByUsername(String username);
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/spring-cloud-config/src/test/java/com/chengbinbbs/SpringCloudConfigApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = SpringCloudConfigApplication.class)
10 | public class SpringCloudConfigApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/spring-cloud-eureka/src/test/java/com/chengbinbbs/SpringCloudEurekaApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = SpringCloudEurekaApplication.class)
10 | public class SpringCloudEurekaApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/spring-cloud-ribbon/src/test/java/com/chengbinbbs/SpringCloudRibbonApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = SpringCloudRibbonApplication.class)
10 | public class SpringCloudRibbonApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/spring-cloud-turbine/src/test/java/com/chengbinbbs/SpringCloudTurbineApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = SpringCloudTurbineApplication.class)
10 | public class SpringCloudTurbineApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/spring-cloud-zuul/src/main/java/com/chengbinbbs/entity/UserEntity.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs.entity;
2 |
3 | /**
4 | * @author zhangcb
5 | * @created 2017-06-15 9:44.
6 | */
7 | import lombok.Data;
8 |
9 | @Data
10 | public class UserEntity {
11 |
12 | private Long id;
13 |
14 | /**
15 | * 账号
16 | */
17 | private String username;
18 |
19 | /**
20 | * 密码
21 | */
22 | private String password;
23 |
24 | /**
25 | * 昵称
26 | */
27 | private String nickname;
28 |
29 | /**
30 | * 权限
31 | */
32 | private String roles;
33 | }
34 |
--------------------------------------------------------------------------------
/spring-cloud-userservice/src/test/java/com/chengbinbbs/SpringCloudUserserviceApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = SpringCloudUserserviceApplication.class)
10 | public class SpringCloudUserserviceApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/spring-cloud-config-client/src/test/java/com/chengbinbbs/SpringCloudConfigClientApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = SpringCloudConfigClientApplication.class)
10 | public class SpringCloudConfigClientApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/spring-cloud-hystrixDashboard/src/main/java/com/chengbinbbs/SpringCloudHystrixdashboardApplication.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
6 |
7 | @EnableHystrixDashboard
8 | @SpringBootApplication
9 | public class SpringCloudHystrixdashboardApplication {
10 |
11 | public static void main(String[] args) {
12 | SpringApplication.run(SpringCloudHystrixdashboardApplication.class, args);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/spring-cloud-hystrixDashboard/src/test/java/com/chengbinbbs/SpringCloudHystrixdashboardApplicationTests.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs;
2 |
3 | import org.junit.Test;
4 | import org.junit.runner.RunWith;
5 | import org.springframework.boot.test.SpringApplicationConfiguration;
6 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
7 |
8 | @RunWith(SpringJUnit4ClassRunner.class)
9 | @SpringApplicationConfiguration(classes = SpringCloudHystrixdashboardApplication.class)
10 | public class SpringCloudHystrixdashboardApplicationTests {
11 |
12 | @Test
13 | public void contextLoads() {
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/spring-cloud-zuul/src/main/java/com/chengbinbbs/SpringCloudZuulApplication.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6 | import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
7 |
8 | @EnableDiscoveryClient
9 | @EnableZuulProxy
10 | @SpringBootApplication
11 | public class SpringCloudZuulApplication {
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(SpringCloudZuulApplication.class, args);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/spring-cloud-config/src/main/java/com/chengbinbbs/SpringCloudConfigApplication.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.config.server.EnableConfigServer;
6 | import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
7 |
8 | @EnableConfigServer
9 | @EnableEurekaClient
10 | @SpringBootApplication
11 | public class SpringCloudConfigApplication {
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(SpringCloudConfigApplication.class, args);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/spring-cloud-feign/src/main/java/com/chengbinbbs/SpringCloudFeignApplication.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6 | import org.springframework.cloud.netflix.feign.EnableFeignClients;
7 |
8 | @EnableDiscoveryClient
9 | @EnableFeignClients
10 | @SpringBootApplication
11 | public class SpringCloudFeignApplication {
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(SpringCloudFeignApplication.class, args);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/spring-cloud-feign/src/main/java/com/chengbinbbs/fallback/UserClientHystrix.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs.fallback;
2 |
3 | import com.chengbinbbs.module.User;
4 | import com.chengbinbbs.service.UserClient;
5 | import org.springframework.stereotype.Component;
6 | import org.springframework.web.bind.annotation.RequestParam;
7 |
8 | /**
9 | * 回调类
10 | *
11 | * @author zhangcb
12 | * @created 2017-05-24 15:03.
13 | */
14 | @Component
15 | public class UserClientHystrix implements UserClient {
16 | @Override
17 | public User addUser(@RequestParam(value = "name") String name, @RequestParam(value = "age") Integer age) {
18 | return new User();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/spring-cloud-config-client/src/main/java/com/chengbinbbs/controller/TestController.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs.controller;
2 |
3 | import org.springframework.beans.factory.annotation.Value;
4 | import org.springframework.cloud.context.config.annotation.RefreshScope;
5 | import org.springframework.web.bind.annotation.RequestMapping;
6 | import org.springframework.web.bind.annotation.RestController;
7 |
8 | /**
9 | * 控制器
10 | *
11 | * @author zhangcb
12 | * @created 2017-05-24 16:25.
13 | */
14 | @RefreshScope
15 | @RestController
16 | public class TestController {
17 |
18 | @Value("${foo}")
19 | private String foo;
20 |
21 | @RequestMapping("/foo")
22 | public String from(){
23 | return foo;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/spring-cloud-eureka/src/main/java/com/chengbinbbs/SpringCloudEurekaApplication.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs;
2 |
3 | import io.prometheus.client.spring.boot.EnablePrometheusEndpoint;
4 | import io.prometheus.client.spring.boot.EnableSpringBootMetricsCollector;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.boot.autoconfigure.SpringBootApplication;
7 | import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
8 |
9 | @EnableEurekaServer
10 | @SpringBootApplication
11 | @EnablePrometheusEndpoint
12 | @EnableSpringBootMetricsCollector
13 | public class SpringCloudEurekaApplication {
14 |
15 | public static void main(String[] args) {
16 | SpringApplication.run(SpringCloudEurekaApplication.class, args);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/spring-cloud-userservice/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=user-service
2 | server.port=2223
3 | spring.aop.auto=true
4 | eureka.client.register-with-eureka=true
5 | eureka.client.fetch-registry=true
6 | eureka.client.serviceUrl.defaultZone=http://peer1:1111/eureka/,http://peer2:1112/eureka/,http://peer3:1113/eureka/
7 |
8 | info.version=0.0.1-SNAPSHOT
9 |
10 | #Client \u7AEF\u7684\u914D\u7F6E\u4E3B\u8981\u662F\u628A\u81EA\u5DF1\u6CE8\u518C\u5230 Eureka Server \u4E2D\u5C31\u53EF\u4EE5\u88AB Spring Boot Admin \u7BA1\u7406\u4E86\uFF0C
11 | #\u514D\u53BB\u4E86\u624B\u5DE5\u914D\u7F6E Spring Boot Admin \u670D\u52A1\u5730\u5740\u7684\u64CD\u4F5C
12 | #\u624B\u5DE5\u914D\u7F6E\u5230Spring Boot Admin\u7BA1\u7406
13 | #spring.boot.admin.url=http://localhost:8088
--------------------------------------------------------------------------------
/spring-cloud-config-client/src/main/resources/bootstrap.properties:
--------------------------------------------------------------------------------
1 | #\u6307\u660E\u914D\u7F6E\u670D\u52A1\u4E2D\u5FC3\u7684\u7F51\u5740
2 | #\u5E94\u7528\u540D\u5FC5\u987B\u8DDFgit\u4E0A\u6587\u4EF6\u53BB\u6389\u540E\u7F00\u540D\u76F8\u540C
3 | spring.application.name=config-client
4 | spring.cloud.config.profile=dev
5 | spring.cloud.config.label=master
6 | #spring.cloud.config.uri=http://localhost:5555/
7 |
8 | #\u662F\u975E\u4ECE\u914D\u7F6E\u4E2D\u5FC3\u8BFB\u53D6\u6587\u4EF6
9 | spring.cloud.config.discovery.enabled=true
10 | #\u914D\u7F6E\u4E2D\u5FC3\u7684servieId\uFF0C\u5373\u670D\u52A1\u540D
11 | spring.cloud.config.discovery.serviceId=config-server
12 | eureka.client.serviceUrl.defaultZone=http://peer1:1111/eureka/,http://peer2:1112/eureka/,http://peer3:1113/eureka/
13 |
14 | server.port=5556
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Windows image file caches
2 | Thumbs.db
3 | ehthumbs.db
4 |
5 | # Folder config file
6 | Desktop.ini
7 |
8 | # Recycle Bin used on file shares
9 | $RECYCLE.BIN/
10 |
11 | # Windows Installer files
12 | *.cab
13 | *.msi
14 | *.msm
15 | *.msp
16 |
17 | # Windows shortcuts
18 | *.lnk
19 |
20 | # =========================
21 | # Operating System Files
22 | # =========================
23 |
24 | # OSX
25 | # =========================
26 |
27 | .DS_Store
28 | .AppleDouble
29 | .LSOverride
30 |
31 | # Thumbnails
32 | ._*
33 |
34 | # Files that might appear in the root of a volume
35 | .DocumentRevisions-V100
36 | .fseventsd
37 | .Spotlight-V100
38 | .TemporaryItems
39 | .Trashes
40 | .VolumeIcon.icns
41 |
42 | # Directories potentially created on remote AFP share
43 | .AppleDB
44 | .AppleDesktop
45 | Network Trash Folder
46 | Temporary Items
47 | .apdisk
48 |
--------------------------------------------------------------------------------
/spring-cloud-userservice/src/main/java/com/chengbinbbs/SpringCloudUserserviceApplication.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs;
2 |
3 | import com.chengbinbbs.module.User;
4 | import org.springframework.boot.CommandLineRunner;
5 | import org.springframework.boot.SpringApplication;
6 | import org.springframework.boot.autoconfigure.SpringBootApplication;
7 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
8 |
9 | @EnableDiscoveryClient
10 | @SpringBootApplication
11 | public class SpringCloudUserserviceApplication implements CommandLineRunner{
12 |
13 | public static void main(String[] args) {
14 | SpringApplication.run(SpringCloudUserserviceApplication.class, args);
15 | }
16 |
17 | @Override
18 | public void run(String... strings) throws Exception {
19 | User user = new User("zhangsan",23);
20 | System.out.println(user.toString());
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/spring-cloud-zuul/src/main/java/com/chengbinbbs/filter/AfterCsrfFilter.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs.filter;
2 |
3 | import org.springframework.web.filter.GenericFilterBean;
4 |
5 | import javax.servlet.FilterChain;
6 | import javax.servlet.ServletException;
7 | import javax.servlet.ServletRequest;
8 | import javax.servlet.ServletResponse;
9 | import java.io.IOException;
10 | /**
11 | * @author zhangcb
12 | * @created 2017-06-15 9:32.
13 | */
14 | public class AfterCsrfFilter extends GenericFilterBean {
15 |
16 | @Override
17 | public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
18 | System.out.println("This is a filter after CsrfFilter.");
19 | // 继续调用 Filter 链
20 | filterChain.doFilter(servletRequest, servletResponse);
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/spring-cloud-feign/src/main/java/com/chengbinbbs/service/UserClient.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs.service;
2 |
3 | import com.chengbinbbs.fallback.UserClientHystrix;
4 | import com.chengbinbbs.module.User;
5 | import org.springframework.cloud.netflix.feign.FeignClient;
6 | import org.springframework.web.bind.annotation.RequestMapping;
7 | import org.springframework.web.bind.annotation.RequestMethod;
8 | import org.springframework.web.bind.annotation.RequestParam;
9 |
10 | /**
11 | * 使用@FeignClient("user-service")注解来绑定该接口对应user-service服务
12 | * @author zhangcb
13 | * @created on 2017/5/24.
14 | */
15 | @FeignClient(value = "user-service",fallback = UserClientHystrix.class)
16 | public interface UserClient {
17 |
18 | @RequestMapping(value = "/user/add",method = RequestMethod.GET)
19 | User addUser(@RequestParam(value = "name") String name, @RequestParam(value = "age") Integer age);
20 | }
21 |
--------------------------------------------------------------------------------
/spring-cloud-zuul/src/main/java/com/chengbinbbs/filter/BeforeLoginFilter.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs.filter;
2 |
3 |
4 | import org.springframework.web.filter.GenericFilterBean;
5 |
6 | import javax.servlet.FilterChain;
7 | import javax.servlet.ServletException;
8 | import javax.servlet.ServletRequest;
9 | import javax.servlet.ServletResponse;
10 | import java.io.IOException;
11 | /**
12 | * @author zhangcb
13 | * @created 2017-06-15 9:32.
14 | */
15 | public class BeforeLoginFilter extends GenericFilterBean {
16 |
17 | @Override
18 | public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
19 | System.out.println("This is a filter before UsernamePasswordAuthenticationFilter.");
20 | // 继续调用 Filter 链
21 | filterChain.doFilter(servletRequest, servletResponse);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/spring-cloud-ribbon/src/main/java/com/chengbinbbs/SpringCloudRibbonApplication.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 | import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
7 | import org.springframework.cloud.client.loadbalancer.LoadBalanced;
8 | import org.springframework.context.annotation.Bean;
9 | import org.springframework.web.client.RestTemplate;
10 |
11 | @EnableCircuitBreaker
12 | @EnableDiscoveryClient
13 | @SpringBootApplication
14 | public class SpringCloudRibbonApplication {
15 |
16 | @Bean
17 | @LoadBalanced
18 | RestTemplate restTemplate(){
19 | return new RestTemplate();
20 | }
21 |
22 | public static void main(String[] args) {
23 | SpringApplication.run(SpringCloudRibbonApplication.class, args);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/spring-cloud-eureka/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #server.port=1111
2 | #spring.application.name=eureka
3 | #
4 | #eureka.client.register-with-eureka=false
5 | #eureka.client.fetch-registry=false
6 | #eureka.client.serviceUrl.defaultZone=http://localhost:${server.port}/eureka/
7 |
8 | spring.profiles.active=peer1
9 |
10 | #Renews threshold\uFF1AEureka Server \u6BCF\u5206\u949F\u671F\u5F85\u6536\u5230\u7684\u7EED\u7EA6\u6570\u91CF
11 | #Renews (last min): \u4E4B\u524D1\u5206\u949F\u5185 Eureka Server \u6536\u5230\u7684\u7EED\u7EA6\u6570\u91CF
12 | #\u8FD0\u884C15\u5206\u949F\u4E4B\u540E\uFF0CEureka Server\u5C31\u8FDB\u5165\u81EA\u6211\u4FDD\u62A4\u6A21\u5F0F\u4E86
13 | #\u5173\u6389Eureka Server\u7684\u81EA\u6211\u4FDD\u62A4\u6A21\u5F0F,\u751F\u4EA7\u73AF\u5883\u4E0D\u63A8\u8350\uFF0C\u4EC5\u9650\u5F00\u53D1\u73AF\u5883
14 | #eureka.server.enable-self-preservation=false
15 | #eureka.server.renewal-threshold-update-interval-ms=1
16 | info.version=0.0.1-SNAPSHOT
--------------------------------------------------------------------------------
/spring-cloud-feign/src/main/java/com/chengbinbbs/controller/UserController.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs.controller;
2 |
3 | import com.chengbinbbs.module.User;
4 | import com.chengbinbbs.service.UserClient;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.web.bind.annotation.RequestMapping;
7 | import org.springframework.web.bind.annotation.RequestMethod;
8 | import org.springframework.web.bind.annotation.RequestParam;
9 | import org.springframework.web.bind.annotation.RestController;
10 |
11 | /**
12 | * 控制器
13 | *
14 | * @author zhangcb
15 | * @created 2017-05-24 14:42.
16 | */
17 | @RestController
18 | public class UserController {
19 |
20 | @Autowired
21 | UserClient userClient;
22 |
23 | @RequestMapping(value = "/user/add",method = RequestMethod.GET)
24 | public User addUser(@RequestParam(value = "name")String name,@RequestParam("age")Integer age){
25 | return userClient.addUser(name,age);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/spring-cloud-feign/src/main/java/com/chengbinbbs/module/User.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs.module;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * 用户实体类
7 | *
8 | * @author zhangcb
9 | * @created 2017-05-24 11:47.
10 | */
11 | public class User implements Serializable {
12 |
13 | private Long id;
14 |
15 | private String name;
16 |
17 | private Integer age;
18 |
19 | public User() {
20 | }
21 |
22 | public User(String name, Integer age) {
23 | this.name = name;
24 | this.age = age;
25 | }
26 |
27 | public Long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(Long id) {
32 | this.id = id;
33 | }
34 |
35 | public String getName() {
36 | return name;
37 | }
38 |
39 | public void setName(String name) {
40 | this.name = name;
41 | }
42 |
43 | public Integer getAge() {
44 | return age;
45 | }
46 |
47 | public void setAge(Integer age) {
48 | this.age = age;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/spring-cloud-ribbon/src/main/java/com/chengbinbbs/module/User.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs.module;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * 用户实体类
7 | *
8 | * @author zhangcb
9 | * @created 2017-05-24 11:47.
10 | */
11 | public class User implements Serializable {
12 |
13 | private Long id;
14 |
15 | private String name;
16 |
17 | private Integer age;
18 |
19 | public User() {
20 | }
21 |
22 | public User(String name, Integer age) {
23 | this.name = name;
24 | this.age = age;
25 | }
26 |
27 | public Long getId() {
28 | return id;
29 | }
30 |
31 | public void setId(Long id) {
32 | this.id = id;
33 | }
34 |
35 | public String getName() {
36 | return name;
37 | }
38 |
39 | public void setName(String name) {
40 | this.name = name;
41 | }
42 |
43 | public Integer getAge() {
44 | return age;
45 | }
46 |
47 | public void setAge(Integer age) {
48 | this.age = age;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/spring-cloud-ribbon/src/main/java/com/chengbinbbs/controller/UserController.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs.controller;
2 |
3 | import com.chengbinbbs.module.User;
4 | import com.chengbinbbs.service.UserService;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.web.bind.annotation.RequestMapping;
7 | import org.springframework.web.bind.annotation.RequestMethod;
8 | import org.springframework.web.bind.annotation.RequestParam;
9 | import org.springframework.web.bind.annotation.RestController;
10 | import org.springframework.web.client.RestTemplate;
11 |
12 | /**
13 | * 控制器
14 | *
15 | * @author zhangcb
16 | * @created 2017-05-24 14:02.
17 | */
18 | @RestController
19 | public class UserController {
20 | @Autowired
21 | UserService userService;
22 |
23 | @RequestMapping(value = "/user/add",method = RequestMethod.GET)
24 | public User addUser(@RequestParam(value = "name")String name,@RequestParam(value = "age")Integer age){
25 | return userService.addUser(name,age);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/spring-cloud-config/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #\u5206\u5E03\u5F0F\u914D\u7F6E\u7BA1\u7406\u4E2D\u5FC3\uFF0C\u7BA1\u7406\u6240\u6709\u7684\u914D\u7F6E\u4FE1\u606F
2 | spring.application.name=config-server
3 | server.port=5555
4 |
5 | #\u5206\u5E03\u5F0F\u914D\u7F6E\u4E2D\u5FC3
6 | #http\u8BF7\u6C42\u5730\u5740\u548C\u8D44\u6E90\u6587\u4EF6\u6620\u5C04\u5982\u4E0B:
7 | #/{application}/{profile}[/{label}]
8 | #/{application}-{profile}.yml
9 | #/{label}/{application}-{profile}.yml
10 | #/{application}-{profile}.properties
11 | #/{label}/{application}-{profile}.properties
12 | spring.cloud.config.server.git.uri=https://github.com/chengbinbbs/SpringcloudConfig/
13 | spring.cloud.config.server.git.search-paths=respo
14 | spring.cloud.config.label=master
15 | spring.cloud.config.server.git.username=${username}
16 | spring.cloud.config.server.git.password=${password}
17 | #\u6CE8\u518C\u5230eureka\uFF0C\u9AD8\u53EF\u7528\u5206\u5E03\u5F0F\u914D\u7F6E\u4E2D\u5FC3
18 | eureka.client.serviceUrl.defaultZone=http://peer1:1111/eureka/,http://peer2:1112/eureka/,http://peer3:1113/eureka/
19 |
20 | info.version=0.0.1-SNAPSHOT
--------------------------------------------------------------------------------
/spring-cloud-zuul/src/main/java/com/chengbinbbs/controller/UserController.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs.controller;
2 |
3 | /**
4 | * @author zhangcb
5 | * @created 2017-06-15 9:51.
6 | */
7 | import com.chengbinbbs.entity.UserEntity;
8 | import org.springframework.security.core.annotation.AuthenticationPrincipal;
9 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
10 | import org.springframework.stereotype.Controller;
11 | import org.springframework.ui.Model;
12 | import org.springframework.web.bind.annotation.GetMapping;
13 |
14 | import java.security.Principal;
15 |
16 | @Controller
17 | public class UserController {
18 |
19 | @GetMapping("/user")
20 | public String user(@AuthenticationPrincipal Principal principal, Model model){
21 | model.addAttribute("username", principal.getName());
22 | return "user/user";
23 | }
24 |
25 | /**
26 | * 用户注册加密密码
27 | */
28 | private void encryptPassword(UserEntity userEntity){
29 | String password = userEntity.getPassword();
30 | password = new BCryptPasswordEncoder().encode(password);
31 | userEntity.setPassword(password);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/spring-cloud-ribbon/src/main/java/com/chengbinbbs/service/UserService.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs.service;
2 |
3 | import com.chengbinbbs.module.User;
4 | import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.stereotype.Service;
7 | import org.springframework.web.client.RestTemplate;
8 |
9 | /**
10 | * 服务层
11 | *
12 | * @author zhangcb
13 | * @created 2017-05-24 14:53.
14 | */
15 | @Service
16 | public class UserService {
17 |
18 | @Autowired
19 | RestTemplate restTemplate;
20 |
21 | /**
22 | * 增加@HystrixCommand注解来指定回调方法
23 | * @param name
24 | * @param age
25 | * @return
26 | */
27 | @HystrixCommand(fallbackMethod = "addUserFallback")
28 | public User addUser(String name,Integer age){
29 | String url = "http://user-service/user/add?name=" + name + "&age=" + age;
30 | return restTemplate.getForEntity(url,User.class).getBody();
31 | }
32 |
33 | /**
34 | * 回调函数,必须跟主函数参数、返回值保持一致,否则会报错
35 | * @param name
36 | * @param age
37 | * @return
38 | */
39 | public User addUserFallback(String name,Integer age){
40 | return new User();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/spring-cloud-ribbon/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=ribbon-consumer
2 | server.port=3333
3 | eureka.client.serviceUrl.defaultZone=eureka.client.serviceUrl.defaultZone=http://peer1:1111/eureka/,http://peer2:1112/eureka/,http://peer3:1113/eureka/
4 |
5 | info.version=0.0.1-SNAPSHOT
6 |
7 | ####\u4E3ASpring Cloud Ribbon\u914D\u7F6E\u8BF7\u6C42\u91CD\u8BD5\uFF08Camden.SR2+\uFF09
8 | #\u5F00\u542F\u91CD\u8BD5\u673A\u5236\uFF0C\u5B83\u9ED8\u8BA4\u662F\u5173\u95ED\u7684
9 | spring.cloud.loadbalancer.retry.enabled=true
10 | #\u65AD\u8DEF\u5668\u7684\u8D85\u65F6\u65F6\u95F4\u9700\u8981\u5927\u4E8Eribbon\u7684\u8D85\u65F6\u65F6\u95F4\uFF0C\u4E0D\u7136\u4E0D\u4F1A\u89E6\u53D1\u91CD\u8BD5
11 | hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=10000
12 | #\u8BF7\u6C42\u8FDE\u63A5\u7684\u8D85\u65F6\u65F6\u95F4
13 | ribbon.ConnectTimeout=250
14 | #\u8BF7\u6C42\u5904\u7406\u7684\u8D85\u65F6\u65F6\u95F4
15 | ribbon.ReadTimeout=1000
16 | #\u5BF9\u6240\u6709\u64CD\u4F5C\u8BF7\u6C42\u90FD\u8FDB\u884C\u91CD\u8BD5
17 | ribbon.OkToRetryOnAllOperations=true
18 | #\u5207\u6362\u5B9E\u4F8B\u7684\u91CD\u8BD5\u6B21\u6570
19 | ribbon.MaxAutoRetriesNextServer=2
20 | #\u5BF9\u5F53\u524D\u5B9E\u4F8B\u7684\u91CD\u8BD5\u6B21\u6570
21 | ribbon.MaxAutoRetries=1
22 |
--------------------------------------------------------------------------------
/spring-cloud-admin/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=8088
2 | spring.application.name=spring-boot-admin
3 | eureka.client.register-with-eureka=true
4 | eureka.client.fetch-registry=true
5 | eureka.client.serviceUrl.defaultZone=http://peer1:1111/eureka/,http://peer2:1112/eureka/,http://peer3:1113/eureka/
6 |
7 |
8 | #\u914D\u7F6E\u8DE8\u57DF\u8BF7\u6C42
9 | endpoints.cors.allowed-origins=http://mobile.daysluck.com
10 | endpoints.cors.allowed-methods=GET,POST
11 |
12 | #Using default security password: fbe88ee2-4ae5-409a-8452-44081fa94e82
13 | #security\u9ED8\u8BA4\u7528\u6237\u540D\u4E3Auser\uFF0C\u9879\u76EE\u542F\u52A8\u65F6\u4F1A\u751F\u6210\u9ED8\u8BA4\u5BC6\u7801Using default security password
14 | #security.user.name=admin
15 | #security.user.password=admin
16 | #management.security.role=superuser
17 | #management.security.enabled=false
18 |
19 | spring.mail.host=smtp.qq.com
20 | spring.boot.admin.notify.mail.to=1437243814@qq.com
21 |
22 | spring.boot.admin.url=http://localhost:${server.port}
23 | spring.jackson.serialization.indent_output=true
24 | endpoints.health.sensitive=false
25 |
26 | info.version=@project.version@
27 | info.build.artifact=@project.artifactId@
28 | info.build.name=@project.name@
29 | info.build.description=@project.description@
30 | info.build.version=@project.version@
--------------------------------------------------------------------------------
/spring-cloud-userservice/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.chengbinbbs
7 | spring-cloud-userservice
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | spring-cloud-userservice
12 | 用户服务
13 |
14 |
15 | com.chengbinbbs
16 | spring-cloud
17 | 0.0.1-SNAPSHOT
18 |
19 |
20 |
21 |
22 | org.springframework.boot
23 | spring-boot-starter-aop
24 |
25 |
26 |
27 | org.springframework.cloud
28 | spring-cloud-starter-eureka
29 |
30 |
31 |
32 |
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-maven-plugin
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/spring-cloud-turbine/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | server.port=8888
2 | eureka.client.serviceUrl.defaultZone=http://peer1:1111/eureka/,http://peer2:1112/eureka/,http://peer3:1113/eureka/
3 | spring.application.name=turbine
4 |
5 | security.basic.enabled=false
6 |
7 | #\u914D\u7F6E\u9700\u8981\u805A\u5408\u7684\u5E94\u7528
8 | turbine.appConfig=api-gateway,user-service,feign-consumer,ribbon-consumer
9 | # \u6307\u5B9A\u805A\u5408\u54EA\u4E9B\u96C6\u7FA4\uFF0C\u591A\u4E2A\u4F7F\u7528","\u5206\u5272\uFF0C\u9ED8\u8BA4\u4E3Adefault\u3002\u53EF\u4F7F\u7528http://.../turbine.stream?cluster={clusterConfig\u4E4B\u4E00}\u8BBF\u95EE
10 | turbine.aggregator.clusterConfig=default
11 |
12 | # 1. clusterNameExpression\u6307\u5B9A\u96C6\u7FA4\u540D\u79F0\uFF0C\u9ED8\u8BA4\u8868\u8FBE\u5F0FappName\uFF1B\u6B64\u65F6\uFF1Aturbine.aggregator.clusterConfig\u9700\u8981\u914D\u7F6E\u60F3\u8981\u76D1\u63A7\u7684\u5E94\u7528\u540D\u79F0
13 | # 2. \u5F53clusterNameExpression: default\u65F6\uFF0Cturbine.aggregator.clusterConfig\u53EF\u4EE5\u4E0D\u5199\uFF0C\u56E0\u4E3A\u9ED8\u8BA4\u5C31\u662Fdefault
14 | # 3. \u5F53clusterNameExpression: metadata['cluster']\u65F6\uFF0C\u5047\u8BBE\u60F3\u8981\u76D1\u63A7\u7684\u5E94\u7528\u914D\u7F6E\u4E86eureka.instance.metadata-map.cluster: ABC\uFF0C\u5219\u9700\u8981\u914D\u7F6E\uFF0C\u540C\u65F6turbine.aggregator.clusterConfig: ABC
15 | turbine.clusterNameExpression=new String("default")
16 | info.version=0.0.1-SNAPSHOT
--------------------------------------------------------------------------------
/spring-cloud-zuul/src/main/resources/user.sql:
--------------------------------------------------------------------------------
1 | /*
2 | Navicat Premium Data Transfer
3 | Source Server : localhost
4 | Source Server Type : MariaDB
5 | Source Server Version : 100206
6 | Source Host : localhost
7 | Source Database : any
8 | Target Server Type : MariaDB
9 | Target Server Version : 100206
10 | File Encoding : utf-8
11 | Date: 06/07/2017 17:05:08 PM
12 | */
13 |
14 | SET NAMES utf8mb4;
15 | SET FOREIGN_KEY_CHECKS = 0;
16 |
17 | -- ----------------------------
18 | -- Table structure for `user`
19 | -- ----------------------------
20 | DROP TABLE IF EXISTS `user`;
21 | CREATE TABLE `user` (
22 | `id` bigint(20) NOT NULL AUTO_INCREMENT,
23 | `username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '账号',
24 | `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '密码',
25 | `nickname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT '' COMMENT '昵称',
26 | `roles` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '身份',
27 | PRIMARY KEY (`id`)
28 | ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4;
29 |
30 | -- ----------------------------
31 | -- Records of `user`
32 | -- ----------------------------
33 | BEGIN;
34 | INSERT INTO `user` VALUES ('1', 'anoy', 'pwd', 'anoy', 'ROLE_USER'), ('2', 'admin', 'pwd', 'admin', 'ROLE_USER,ROLE_ADMIN');
35 | COMMIT;
36 |
37 | SET FOREIGN_KEY_CHECKS = 1;
--------------------------------------------------------------------------------
/spring-cloud-userservice/src/main/java/com/chengbinbbs/aop/ServiceMonitor.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs.aop;
2 |
3 | import org.aspectj.lang.JoinPoint;
4 | import org.aspectj.lang.ProceedingJoinPoint;
5 | import org.aspectj.lang.annotation.Around;
6 | import org.aspectj.lang.annotation.Aspect;
7 | import org.aspectj.lang.annotation.Before;
8 | import org.springframework.beans.factory.annotation.Autowired;
9 | import org.springframework.boot.actuate.metrics.CounterService;
10 | import org.springframework.boot.actuate.metrics.GaugeService;
11 | import org.springframework.stereotype.Component;
12 |
13 | /**
14 | * 统计方法调用次数
15 | *
16 | * @author zhangcb
17 | * @created 2017-06-06 10:53.
18 | */
19 | @Aspect
20 | @Component
21 | public class ServiceMonitor {
22 | @Autowired
23 | private CounterService counterService; //统计每个接口调用次数
24 | @Autowired
25 | private GaugeService gaugeService; //统计每个接口调用时长
26 |
27 | @Before("execution(* com.chengbinbbs.controller.*.*(..))")
28 | public void countServiceInvoke(JoinPoint joinPoint) {
29 | counterService.increment(joinPoint.getSignature() + "");
30 | }
31 |
32 | @Around("execution(* com.chengbinbbs.controller.*.*(..))")
33 | public void latencyService(ProceedingJoinPoint pjp) throws Throwable {
34 | long start = System.currentTimeMillis();
35 | pjp.proceed();
36 | long end = System.currentTimeMillis();
37 | gaugeService.submit(pjp.getSignature().toString(), end - start);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/spring-cloud-zuul/src/test/java/com/chengbinbbs/DistributedBolckingQueueTest.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs;
2 |
3 | import com.chengbinbbs.distribute.queue.DistributedBlockingQueue;
4 | import org.apache.zookeeper.KeeperException;
5 | import org.junit.Test;
6 | import org.slf4j.Logger;
7 | import org.slf4j.LoggerFactory;
8 |
9 | /**
10 | * 测试
11 | *
12 | * @author zhangcb
13 | * @created 2017-05-27 16:34.
14 | */
15 | public class DistributedBolckingQueueTest {
16 |
17 | private final Logger logger = LoggerFactory.getLogger(DistributedBolckingQueueTest.class);
18 |
19 |
20 | @Test
21 | public void test() throws InterruptedException, KeeperException {
22 | //用多线程模拟分布式服务
23 | for (int i = 0; i < 10; i++) {
24 | new Thread(new Runnable() {
25 | @Override
26 | public void run() {
27 | DistributedBlockingQueue queue=new DistributedBlockingQueue("120.27.xxx.xx:2181", "test");
28 | try {
29 | queue.put(Thread.currentThread().getName().getBytes());
30 | } catch (KeeperException e) {
31 | e.printStackTrace();
32 | } catch (InterruptedException e) {
33 | e.printStackTrace();
34 | }
35 | }
36 | }).start();
37 | }
38 |
39 | DistributedBlockingQueue queue=new DistributedBlockingQueue("120.27.141.45:2181", "test");
40 | while(true){
41 | System.out.println(new String(queue.tack()));
42 | }
43 | }
44 |
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/spring-cloud-userservice/src/main/java/com/chengbinbbs/controller/UserController.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs.controller;
2 |
3 | import com.chengbinbbs.module.User;
4 | import com.google.common.collect.Maps;
5 | import org.apache.log4j.Logger;
6 | import org.springframework.beans.factory.annotation.Autowired;
7 | import org.springframework.cloud.client.ServiceInstance;
8 | import org.springframework.cloud.client.discovery.DiscoveryClient;
9 | import org.springframework.web.bind.annotation.RequestMapping;
10 | import org.springframework.web.bind.annotation.RequestMethod;
11 | import org.springframework.web.bind.annotation.RequestParam;
12 | import org.springframework.web.bind.annotation.RestController;
13 |
14 | import java.util.Map;
15 |
16 | /**
17 | * 控制器
18 | *
19 | * @author zhangcb
20 | * @created 2017-05-24 11:40.
21 | */
22 | @RestController
23 | @RequestMapping("/user")
24 | public class UserController {
25 |
26 | private final Logger logger = Logger.getLogger(getClass());
27 |
28 | @Autowired
29 | DiscoveryClient discoveryClient;
30 |
31 | private static Map users = Maps.newConcurrentMap();
32 |
33 | @RequestMapping(value = "/add",method = RequestMethod.GET)
34 | public User addUser(@RequestParam(value = "name") String name,@RequestParam(value = "age")Integer age){
35 | ServiceInstance instance = discoveryClient.getLocalServiceInstance();
36 | logger.info("/addUser,host:" + instance.getHost() + ",port:" + instance.getPort() +",serviceId:" + instance.getServiceId());
37 | User user = new User(name,age);
38 | users.put(name,user);
39 | return user;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/spring-cloud-admin/src/main/java/com/chengbinbbs/SpringCloudAdminApplication.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs;
2 |
3 | import de.codecentric.boot.admin.config.EnableAdminServer;
4 | import org.springframework.boot.SpringApplication;
5 | import org.springframework.boot.autoconfigure.SpringBootApplication;
6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
7 |
8 | @EnableAdminServer
9 | @SpringBootApplication
10 | @EnableDiscoveryClient
11 | public class SpringCloudAdminApplication {
12 |
13 | // @Configuration
14 | // public static class SecurityConfig extends WebSecurityConfigurerAdapter {
15 | // @Override
16 | // protected void configure(HttpSecurity http) throws Exception {
17 | // // Page with login form is served as /login.html and does a POST on /login
18 | // http.formLogin().loginPage("/login.html").loginProcessingUrl("/login").permitAll();
19 | // // The UI does a POST on /logout on logout
20 | // http.logout().logoutUrl("/logout");
21 | // // The ui currently doesn't support csrf
22 | // http.csrf().disable();
23 | //
24 | // // Requests for the login page and the static assets are allowed
25 | // http.authorizeRequests()
26 | // .antMatchers("/login.html", "/**/*.css", "/img/**", "/third-party/**")
27 | // .permitAll();
28 | // // ... and any other request needs to be authorized
29 | // http.authorizeRequests().antMatchers("/**").authenticated();
30 | //
31 | // // Enable so that the clients can authenticate via HTTP basic for registering
32 | // http.httpBasic();
33 | // }
34 | // }
35 |
36 | public static void main(String[] args) {
37 | SpringApplication.run(SpringCloudAdminApplication.class, args);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/spring-cloud-zuul/src/test/java/com/chengbinbbs/DistributedLockTest.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs;
2 |
3 | import com.chengbinbbs.distribute.locks.DistributedLock;
4 | import org.apache.zookeeper.KeeperException;
5 | import org.junit.Test;
6 | import org.slf4j.Logger;
7 | import org.slf4j.LoggerFactory;
8 |
9 | /**
10 | * 测试
11 | *
12 | * @author zhangcb
13 | * @created 2017-05-27 16:35.
14 | */
15 | public class DistributedLockTest {
16 |
17 | private final Logger logger = LoggerFactory.getLogger(DistributedLockTest.class);
18 |
19 | @Test
20 | public void test() throws InterruptedException {
21 | //用多线程模拟分布式服务
22 | for (int i = 0; i < 10; i++) {
23 | new Thread(new Runnable() {
24 | @Override
25 | public void run() {
26 | DistributedLock lock = new DistributedLock("120.27.xxx.xx:2181", "test");
27 | try {
28 | lock.lock();
29 | } catch (KeeperException e) {
30 | e.printStackTrace();
31 | } catch (InterruptedException e) {
32 | e.printStackTrace();
33 | }
34 | logger.info(Thread.currentThread().getName() + " 开始执行操作!!!");
35 | try {
36 | Thread.sleep(1000);
37 | } catch (InterruptedException e) {
38 | e.printStackTrace();
39 | }
40 | logger.info(Thread.currentThread().getName() + " 执行结束!!!" );
41 | lock.unlock();
42 | }
43 | }).start();
44 | }
45 | while(true){
46 |
47 | }
48 | }
49 |
50 |
51 | }
52 |
53 |
--------------------------------------------------------------------------------
/spring-cloud-zuul/src/main/java/com/chengbinbbs/filter/AccessFilter.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs.filter;
2 |
3 | import com.netflix.zuul.ZuulFilter;
4 | import com.netflix.zuul.context.RequestContext;
5 | import org.slf4j.Logger;
6 | import org.slf4j.LoggerFactory;
7 |
8 | import javax.servlet.http.HttpServletRequest;
9 |
10 | /**
11 | * 服务过滤
12 | *
13 | * @author zhangcb
14 | * @created 2017-05-24 16:56.
15 | */
16 | public class AccessFilter extends ZuulFilter {
17 |
18 | private static Logger log = LoggerFactory.getLogger(AccessFilter.class);
19 |
20 | /**
21 | * pre:可以在请求被路由之前调用
22 | routing:在路由请求时候被调用
23 | post:在routing和error过滤器之后被调用
24 | error:处理请求时发生错误时被调用
25 | * @return
26 | */
27 | @Override
28 | public String filterType() {
29 | return "pre";
30 | }
31 |
32 | /**
33 | * 通过int值来定义过滤器的执行顺序
34 | * @return
35 | */
36 | @Override
37 | public int filterOrder() {
38 | return 0;
39 | }
40 |
41 | /**
42 | * 返回一个boolean类型来判断该过滤器是否要执行,
43 | * 所以通过此函数可实现过滤器的开关。在上例中,我们直接返回true,所以该过滤器总是生效
44 | * @return
45 | */
46 | @Override
47 | public boolean shouldFilter() {
48 | return true;
49 | }
50 |
51 | /**
52 | * 过滤器的具体逻辑。需要注意,这里我们通过ctx.setSendZuulResponse(false)令zuul过滤该请求,
53 | * 不对其进行路由,然后通过ctx.setResponseStatusCode(401)设置了其返回的错误码,
54 | * 当然我们也可以进一步优化我们的返回,比如,通过ctx.setResponseBody(body)对返回body内容进行编辑等
55 | * @return
56 | */
57 | @Override
58 | public Object run() {
59 | RequestContext ctx = RequestContext.getCurrentContext();
60 | HttpServletRequest request = ctx.getRequest();
61 | log.info(String.format("%s request to %s", request.getMethod(), request.getRequestURL().toString()));
62 | Object accessToken = request.getParameter("accessToken");
63 | if(accessToken == null) {
64 | log.warn("access token is empty");
65 | ctx.setSendZuulResponse(false);
66 | ctx.setResponseStatusCode(401);
67 | return null;
68 | }
69 | log.info("access token ok");
70 | return null;
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/spring-cloud-zuul/src/main/java/com/chengbinbbs/oauth/db/AnyUserDetailsService.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs.oauth.db;
2 |
3 | import com.chengbinbbs.entity.UserEntity;
4 | import com.chengbinbbs.service.UserService;
5 | import org.springframework.beans.factory.annotation.Autowired;
6 | import org.springframework.security.core.authority.SimpleGrantedAuthority;
7 | import org.springframework.security.core.userdetails.User;
8 | import org.springframework.security.core.userdetails.UserDetails;
9 | import org.springframework.security.core.userdetails.UserDetailsService;
10 | import org.springframework.security.core.userdetails.UsernameNotFoundException;
11 | import org.springframework.stereotype.Service;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | @Service
17 | public class AnyUserDetailsService implements UserDetailsService {
18 |
19 | private final UserService userService;
20 |
21 | @Autowired
22 | AnyUserDetailsService(UserService userService){
23 | this.userService = userService;
24 | }
25 |
26 | @Override
27 | public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
28 | UserEntity userEntity = userService.getByUsername(username);
29 | if (userEntity == null){
30 | throw new UsernameNotFoundException("用户不存在!");
31 | }
32 | List simpleGrantedAuthorities = createAuthorities(userEntity.getRoles());
33 | return new User(userEntity.getUsername(), userEntity.getPassword(), simpleGrantedAuthorities);
34 | }
35 |
36 | /**
37 | * 权限字符串转化
38 | *
39 | * 如 "USER,ADMIN" -> SimpleGrantedAuthority("USER") + SimpleGrantedAuthority("ADMIN")
40 | *
41 | * @param roleStr 权限字符串
42 | */
43 | private List createAuthorities(String roleStr){
44 | String[] roles = roleStr.split(",");
45 | List simpleGrantedAuthorities = new ArrayList<>();
46 | for (String role : roles) {
47 | simpleGrantedAuthorities.add(new SimpleGrantedAuthority(role));
48 | }
49 | return simpleGrantedAuthorities;
50 | }
51 |
52 | }
--------------------------------------------------------------------------------
/spring-cloud-zuul/src/main/java/com/chengbinbbs/oauth/db/WebSecurityConfig.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs.oauth.db;
2 |
3 |
4 | import org.springframework.beans.factory.annotation.Autowired;
5 | import org.springframework.context.annotation.Bean;
6 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
7 | import org.springframework.security.config.annotation.web.builders.HttpSecurity;
8 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
9 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
10 |
11 | /**
12 | * 权限认证,用户名密码存放在数据库
13 | * @author zhangcb
14 | * @created 2017-06-15 9:42.
15 | */
16 | //@EnableWebSecurity
17 | public class WebSecurityConfig extends WebSecurityConfigurerAdapter{
18 |
19 | private AnyUserDetailsService anyUserDetailsService;
20 |
21 | @Autowired
22 | public void setAnyUserDetailsService(AnyUserDetailsService anyUserDetailsService){
23 | this.anyUserDetailsService = anyUserDetailsService;
24 | }
25 |
26 | /**
27 | * 匹配 "/" 路径,不需要权限即可访问
28 | * 匹配 "/user" 及其以下所有路径,都需要 "USER" 权限
29 | * 登录地址为 "/login",登录成功默认跳转到页面 "/user"
30 | * 退出登录的地址为 "/logout",退出成功后跳转到页面 "/login"
31 | * 默认启用 CSRF
32 | */
33 | @Override
34 | protected void configure(HttpSecurity http) throws Exception {
35 | http
36 | .authorizeRequests()
37 | .antMatchers("/").permitAll()
38 | .antMatchers("/user/**").hasRole("USER")
39 | .and()
40 | .formLogin().loginPage("/login").defaultSuccessUrl("/user")
41 | .and()
42 | .logout().logoutUrl("/logout").logoutSuccessUrl("/login");
43 | }
44 |
45 | /**
46 | * 添加 UserDetailsService, 实现自定义登录校验
47 | */
48 | @Override
49 | protected void configure(AuthenticationManagerBuilder builder) throws Exception{
50 | builder.userDetailsService(anyUserDetailsService);
51 | }
52 |
53 | /**
54 | * 密码加密
55 | */
56 | @Bean
57 | public BCryptPasswordEncoder passwordEncoder(){
58 | return new BCryptPasswordEncoder();
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/spring-cloud-zuul/src/main/java/com/chengbinbbs/oauth/WebSecurityConfig.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs.oauth;
2 |
3 | import com.chengbinbbs.filter.AfterCsrfFilter;
4 | import com.chengbinbbs.filter.BeforeLoginFilter;
5 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
6 | import org.springframework.security.config.annotation.web.builders.HttpSecurity;
7 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
8 |
9 | /**
10 | * 权限认证
11 | * 用户名、密码存放在内存中
12 | * @author zhangcb
13 | * @created 2017-05-25 11:59.
14 | */
15 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
16 | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
17 | import org.springframework.security.web.csrf.CsrfFilter;
18 |
19 | @EnableWebSecurity
20 | public class WebSecurityConfig extends WebSecurityConfigurerAdapter{
21 |
22 | /**
23 | * 匹配 "/" 路径,不需要权限即可访问
24 | * 匹配 "/user" 及其以下所有路径,都需要 "USER" 权限
25 | * 登录地址为 "/login",登录成功默认跳转到页面 "/user"
26 | * 退出登录的地址为 "/logout",退出成功后跳转到页面 "/login"
27 | * 默认启用 CSRF
28 | */
29 | @Override
30 | protected void configure(HttpSecurity http) throws Exception {
31 | http
32 | .authorizeRequests()
33 | .antMatchers("/").permitAll()
34 | .antMatchers("/user/**").hasRole("USER")
35 | .and()
36 | .formLogin().loginPage("/login").defaultSuccessUrl("/user")
37 | .and()
38 | .logout().logoutUrl("/logout").logoutSuccessUrl("/login");
39 |
40 | // 在 UsernamePasswordAuthenticationFilter 前添加 BeforeLoginFilter
41 | http.addFilterBefore(new BeforeLoginFilter(), UsernamePasswordAuthenticationFilter.class);
42 |
43 | // 在 CsrfFilter 后添加 AfterCsrfFilter
44 | http.addFilterAfter(new AfterCsrfFilter(), CsrfFilter.class);
45 | }
46 |
47 | /**
48 | * 在内存中创建一个名为 "anoy" 的用户,密码为 "pwd",拥有 "USER" 权限
49 | */
50 | @Override
51 | protected void configure(AuthenticationManagerBuilder builder) throws Exception{
52 | builder
53 | .inMemoryAuthentication()
54 | .withUser("anoy").password("pwd").roles("USER");
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/spring-cloud-turbine/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.chengbinbbs
7 | spring-cloud-turbine
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | spring-cloud-turbine
12 | 监控集群
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.2.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.7
25 | Brixton.RELEASE
26 |
27 |
28 |
29 |
30 | org.springframework.boot
31 | spring-boot-starter
32 |
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-starter-test
37 | test
38 |
39 |
40 |
41 | org.springframework.cloud
42 | spring-cloud-starter-turbine
43 |
44 |
45 | org.springframework.cloud
46 | spring-cloud-netflix-turbine
47 |
48 |
49 |
50 |
51 | org.springframework.boot
52 | spring-boot-starter-actuator
53 |
54 |
55 | org.jolokia
56 | jolokia-core
57 |
58 |
59 |
60 |
61 |
62 |
63 | org.springframework.cloud
64 | spring-cloud-dependencies
65 | ${spring-cloud.version}
66 | pom
67 | import
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 | org.springframework.boot
76 | spring-boot-maven-plugin
77 |
78 |
79 |
80 |
81 |
82 |
83 |
--------------------------------------------------------------------------------
/spring-cloud-config/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.chengbinbbs
7 | spring-cloud-config
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | spring-cloud-config
12 | 分布式服务配置中心
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.8.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.7
25 | Brixton.RELEASE
26 |
27 |
28 |
29 |
30 | org.springframework.boot
31 | spring-boot-starter
32 |
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-starter-test
37 | test
38 |
39 |
40 |
41 | org.springframework.cloud
42 | spring-cloud-config-server
43 |
44 |
45 |
46 | org.springframework.cloud
47 | spring-cloud-starter-eureka
48 |
49 |
50 |
51 |
52 | org.springframework.boot
53 | spring-boot-starter-actuator
54 |
55 |
56 | org.jolokia
57 | jolokia-core
58 |
59 |
60 |
61 |
62 |
63 |
64 | org.springframework.cloud
65 | spring-cloud-dependencies
66 | ${spring-cloud.version}
67 | pom
68 | import
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | org.springframework.boot
77 | spring-boot-maven-plugin
78 |
79 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.chengbinbbs
8 | spring-cloud
9 | 0.0.1-SNAPSHOT
10 | pom
11 |
12 | org.springframework.cloud
13 | spring-cloud-starter-parent
14 | Brixton.RELEASE
15 |
16 |
17 |
18 | spring-cloud-admin
19 | spring-cloud-config
20 | spring-cloud-eureka
21 | spring-cloud-userservice
22 | spring-cloud-ribbon
23 | spring-cloud-feign
24 | spring-cloud-zuul
25 | spring-cloud-hystrixDashboard
26 | spring-cloud-turbine
27 |
28 |
29 |
30 | UTF-8
31 | UTF-8
32 | 1.4.3.RELEASE
33 | 1.7
34 |
35 |
36 |
37 |
38 | org.springframework.boot
39 | spring-boot-starter-web
40 |
41 |
42 |
43 |
44 | org.springframework.boot
45 | spring-boot-starter-actuator
46 |
47 |
48 |
49 | org.jolokia
50 | jolokia-core
51 |
52 |
53 |
54 | org.projectlombok
55 | lombok
56 | 1.16.10
57 |
58 |
59 |
60 | org.springframework.boot
61 | spring-boot-starter
62 |
63 |
64 |
65 | org.springframework.boot
66 | spring-boot-starter-test
67 | test
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/spring-cloud-hystrixDashboard/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.chengbinbbs
7 | spring-cloud-hystrixdashboard
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | spring-cloud-hystrixdashboard
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.8.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.7
25 | Brixton.RELEASE
26 |
27 |
28 |
29 |
30 | org.springframework.boot
31 | spring-boot-starter
32 |
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-starter-test
37 | test
38 |
39 |
40 |
41 | org.springframework.boot
42 | spring-boot-starter-actuator
43 |
44 |
45 |
46 | org.springframework.cloud
47 | spring-cloud-starter-hystrix-dashboard
48 |
49 |
50 |
51 |
52 | org.springframework.boot
53 | spring-boot-starter-actuator
54 |
55 |
56 | org.jolokia
57 | jolokia-core
58 |
59 |
60 |
61 |
62 |
63 |
64 | org.springframework.cloud
65 | spring-cloud-dependencies
66 | ${spring-cloud.version}
67 | pom
68 | import
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | org.springframework.boot
77 | spring-boot-maven-plugin
78 |
79 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/spring-cloud-feign/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.chengbinbbs
7 | spring-cloud-feign
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | spring-cloud-feign
12 | feign服务消费者
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.8.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.7
25 | Brixton.RELEASE
26 |
27 |
28 |
29 |
30 | org.springframework.boot
31 | spring-boot-starter
32 |
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-starter-test
37 | test
38 |
39 |
40 |
41 | org.springframework.boot
42 | spring-boot-starter-web
43 |
44 |
45 |
46 | org.springframework.cloud
47 | spring-cloud-starter-feign
48 |
49 |
50 |
51 | org.springframework.cloud
52 | spring-cloud-starter-eureka
53 |
54 |
55 |
56 |
57 | org.springframework.boot
58 | spring-boot-starter-actuator
59 |
60 |
61 | org.jolokia
62 | jolokia-core
63 |
64 |
65 |
66 |
67 |
68 |
69 | org.springframework.cloud
70 | spring-cloud-dependencies
71 | ${spring-cloud.version}
72 | pom
73 | import
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | org.springframework.boot
82 | spring-boot-maven-plugin
83 |
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/spring-cloud-config-client/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.chengbinbbs
7 | spring-cloud-config-client
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | spring-cloud-config-client
12 | Demo project for Spring Boot
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.8.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.7
25 | Brixton.RELEASE
26 |
27 |
28 |
29 |
30 | org.springframework.boot
31 | spring-boot-starter
32 |
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-starter-test
37 | test
38 |
39 |
40 |
41 | org.springframework.boot
42 | spring-boot-starter-web
43 |
44 |
45 |
46 | org.springframework.cloud
47 | spring-cloud-starter-config
48 |
49 |
50 |
51 | org.springframework.cloud
52 | spring-cloud-starter-eureka
53 |
54 |
55 |
56 |
57 | org.springframework.boot
58 | spring-boot-starter-actuator
59 |
60 |
61 | org.jolokia
62 | jolokia-core
63 |
64 |
65 |
66 |
67 |
68 |
69 | org.springframework.cloud
70 | spring-cloud-dependencies
71 | ${spring-cloud.version}
72 | pom
73 | import
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | org.springframework.boot
82 | spring-boot-maven-plugin
83 |
84 |
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/spring-cloud-eureka/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.chengbinbbs
7 | spring-cloud-eureka
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | spring-cloud-eureka
12 | 服务注册中心
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.8.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.7
25 | Brixton.RELEASE
26 |
27 |
28 |
29 |
30 | org.springframework.boot
31 | spring-boot-starter
32 |
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-starter-test
37 | test
38 |
39 |
40 |
41 | org.springframework.cloud
42 | spring-cloud-starter-eureka-server
43 |
44 |
45 |
46 |
47 | org.springframework.boot
48 | spring-boot-starter-actuator
49 |
50 |
51 | org.jolokia
52 | jolokia-core
53 |
54 |
55 |
56 |
57 | io.prometheus
58 | simpleclient_spring_boot
59 | 0.0.26
60 |
61 |
62 |
63 | org.springframework.boot
64 | spring-boot-starter-security
65 |
66 |
67 |
68 |
69 |
70 |
71 | org.springframework.cloud
72 | spring-cloud-dependencies
73 | ${spring-cloud.version}
74 | pom
75 | import
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | org.springframework.boot
85 | spring-boot-maven-plugin
86 |
87 |
88 |
89 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/spring-cloud-zuul/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | spring.application.name=api-gateway
2 | server.port=7777
3 |
4 | #\u4E0D\u4EC5\u4EC5\u5B9E\u73B0\u4E86\u8DEF\u7531\u529F\u80FD\u6765\u5C4F\u853D\u8BF8\u591A\u670D\u52A1\u7EC6\u8282\uFF0C\u66F4\u5B9E\u73B0\u4E86\u670D\u52A1\u7EA7\u522B\u3001\u5747\u8861\u8D1F\u8F7D\u7684\u8DEF\u7531\u3002
5 | #\u5B9E\u73B0\u4E86\u63A5\u53E3\u6743\u9650\u6821\u9A8C\u4E0E\u5FAE\u670D\u52A1\u4E1A\u52A1\u903B\u8F91\u7684\u89E3\u8026\u3002\u901A\u8FC7\u670D\u52A1\u7F51\u5173\u4E2D\u7684\u8FC7\u6EE4\u5668\uFF0C\u5728\u5404\u751F\u547D\u5468\u671F\u4E2D\u53BB\u6821\u9A8C\u8BF7\u6C42\u7684\u5185\u5BB9\uFF0C\u5C06\u539F\u672C\u5728\u5BF9\u5916\u670D\u52A1\u5C42\u505A\u7684\u6821\u9A8C\u524D\u79FB\uFF0C\u4FDD\u8BC1\u4E86\u5FAE\u670D\u52A1\u7684\u65E0\u72B6\u6001\u6027\uFF0C\u540C\u65F6\u964D\u4F4E\u4E86\u5FAE\u670D\u52A1\u7684\u6D4B\u8BD5\u96BE\u5EA6\uFF0C\u8BA9\u670D\u52A1\u672C\u8EAB\u66F4\u96C6\u4E2D\u5173\u6CE8\u4E1A\u52A1\u903B\u8F91\u7684\u5904\u7406\u3002
6 | #\u5B9E\u73B0\u4E86\u65AD\u8DEF\u5668\uFF0C\u4E0D\u4F1A\u56E0\u4E3A\u5177\u4F53\u5FAE\u670D\u52A1\u7684\u6545\u969C\u800C\u5BFC\u81F4\u670D\u52A1\u7F51\u5173\u7684\u963B\u585E\uFF0C\u4F9D\u7136\u53EF\u4EE5\u5BF9\u5916\u670D\u52A1\u3002
7 |
8 | #Zuul\u4E2D\u63D0\u4F9B\u4E86\u4E24\u79CD\u8DEF\u7531\u65B9\u5F0F(\u670D\u52A1\u8DEF\u7531\u65B9\u5F0F)
9 |
10 | #1.\u901A\u8FC7url\u76F4\u63A5\u6620\u5C04
11 | #\u914D\u7F6E\u5C5E\u6027zuul.routes.api-a-url.path\u4E2D\u7684api-a-url\u90E8\u5206\u4E3A\u8DEF\u7531\u7684\u540D\u5B57\uFF0C\u53EF\u4EE5\u4EFB\u610F\u5B9A\u4E49\uFF0C\u4F46\u662F\u4E00\u7EC4\u6620\u5C04\u5173\u7CFB\u7684path\u548Curl\u8981\u76F8\u540C
12 | #zuul.routes.api-a-url.path=/user/**
13 | #zuul.routes.api-a-url.url=http://localhost:2222/user/
14 |
15 | #zuul.routes.api-b-url.path=/user/**
16 | #zuul.routes.api-b-url.url=http://localhost:2223/user/
17 |
18 | #2.\u901A\u8FC7serviceId\u6620\u5C04
19 | #\u901A\u8FC7url\u6620\u5C04\u7684\u65B9\u5F0F\u5BF9\u4E8EZuul\u6765\u8BF4\uFF0C\u5E76\u4E0D\u662F\u7279\u522B\u53CB\u597D\uFF0CZuul\u9700\u8981\u77E5\u9053\u6211\u4EEC\u6240\u6709\u4E3A\u670D\u52A1\u7684\u5730\u5740\uFF0C\u624D\u80FD\u5B8C\u6210\u6240\u6709\u7684\u6620\u5C04\u914D\u7F6E
20 |
21 | #\u63A8\u8350\u4F7F\u7528serviceId\u7684\u6620\u5C04\u65B9\u5F0F\uFF0C\u9664\u4E86\u5BF9Zuul\u7EF4\u62A4\u4E0A\u66F4\u52A0\u53CB\u597D\u4E4B\u5916\uFF0CserviceId\u6620\u5C04\u65B9\u5F0F\u8FD8\u652F\u6301\u4E86\u65AD\u8DEF\u5668\uFF0C
22 | #\u5BF9\u4E8E\u670D\u52A1\u6545\u969C\u7684\u60C5\u51B5\u4E0B\uFF0C\u53EF\u4EE5\u6709\u6548\u7684\u9632\u6B62\u6545\u969C\u8513\u5EF6\u5230\u670D\u52A1\u7F51\u5173\u4E0A\u800C\u5F71\u54CD\u6574\u4E2A\u7CFB\u7EDF\u7684\u5BF9\u5916\u670D\u52A1
23 | zuul.routes.api-a-url.path=/user/**
24 | zuul.routes.api-a-url.serviceId=user-service
25 |
26 | zuul.routes.api-b-url.path=/user/**
27 | zuul.routes.api-b-url.serviceId=user-service
28 |
29 | eureka.client.serviceUrl.defaultZone=http://peer1:1111/eureka/,http://peer2:1112/eureka/,http://peer3:1113/eureka/
30 | info.version=0.0.1-SNAPSHOT
--------------------------------------------------------------------------------
/spring-cloud-ribbon/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.chengbinbbs
7 | spring-cloud-ribbon
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | spring-cloud-ribbon
12 | ribbon服务消费者
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.4.3.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.7
25 | Camden.SR7
26 |
27 |
28 |
29 |
30 | org.springframework.boot
31 | spring-boot-starter
32 |
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-starter-test
37 | test
38 |
39 |
40 | org.springframework.boot
41 | spring-boot-starter-web
42 |
43 |
44 |
45 | org.springframework.cloud
46 | spring-cloud-starter-ribbon
47 |
48 |
49 |
50 | org.springframework.cloud
51 | spring-cloud-starter-eureka
52 |
53 |
54 |
55 | org.springframework.cloud
56 | spring-cloud-starter-hystrix
57 |
58 |
59 |
60 |
61 | org.springframework.boot
62 | spring-boot-starter-actuator
63 |
64 |
65 | org.jolokia
66 | jolokia-core
67 |
68 |
69 |
70 |
71 |
72 |
73 | org.springframework.cloud
74 | spring-cloud-dependencies
75 | ${spring-cloud.version}
76 | pom
77 | import
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 | org.springframework.boot
86 | spring-boot-maven-plugin
87 |
88 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/spring-cloud-zuul/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.chengbinbbs
7 | spring-cloud-zuul
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | spring-cloud-zuul
12 | 服务网关
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.4.3.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.7
25 | Brixton.RELEASE
26 |
27 |
28 |
29 |
30 | org.springframework.boot
31 | spring-boot-starter
32 |
33 |
34 |
35 | org.springframework.boot
36 | spring-boot-starter-test
37 | test
38 |
39 |
40 |
41 | org.springframework.boot
42 | spring-boot-starter-web
43 |
44 |
45 |
46 | org.springframework.cloud
47 | spring-cloud-starter-oauth2
48 |
49 |
50 |
51 | org.springframework.cloud
52 | spring-cloud-starter-zuul
53 |
54 |
55 |
56 | org.springframework.cloud
57 | spring-cloud-starter-eureka
58 |
59 |
60 |
61 |
62 | org.springframework.boot
63 | spring-boot-starter-actuator
64 |
65 |
66 | org.jolokia
67 | jolokia-core
68 |
69 |
70 |
71 | org.projectlombok
72 | lombok
73 | 1.16.10
74 |
75 |
76 |
77 | org.apache.zookeeper
78 | zookeeper
79 | 3.4.6
80 |
81 |
82 | com.github.sgroschupf
83 | zkclient
84 | 0.1
85 |
86 |
87 |
88 |
89 |
90 |
91 | org.springframework.cloud
92 | spring-cloud-dependencies
93 | ${spring-cloud.version}
94 | pom
95 | import
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 | org.springframework.boot
104 | spring-boot-maven-plugin
105 |
106 |
107 |
108 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/spring-cloud-admin/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 |
6 | com.chengbinbbs
7 | spring-cloud-admin
8 | 0.0.1-SNAPSHOT
9 | jar
10 |
11 | spring-cloud-admin
12 | 分布式监控中心
13 |
14 |
15 | org.springframework.boot
16 | spring-boot-starter-parent
17 | 1.3.8.RELEASE
18 |
19 |
20 |
21 |
22 | UTF-8
23 | UTF-8
24 | 1.7
25 | 1.3.4
26 | Brixton.RELEASE
27 |
28 |
29 |
30 |
31 | org.springframework.boot
32 | spring-boot-starter
33 |
34 |
35 |
36 | org.springframework.boot
37 | spring-boot-starter-test
38 | test
39 |
40 |
41 |
42 | org.springframework.cloud
43 | spring-cloud-starter-eureka-server
44 |
45 |
46 |
47 | de.codecentric
48 | spring-boot-admin-server
49 | ${spring-boot-admin.version}
50 |
51 |
52 | de.codecentric
53 | spring-boot-admin-server-ui
54 | ${spring-boot-admin.version}
55 |
56 |
57 | org.jolokia
58 | jolokia-core
59 |
60 |
61 |
62 | org.springframework.boot
63 | spring-boot-starter-mail
64 |
65 |
66 |
71 |
75 |
76 |
77 |
78 |
79 |
80 | org.springframework.cloud
81 | spring-cloud-dependencies
82 | ${spring-cloud.version}
83 | pom
84 | import
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 | src/main/resources
93 | true
94 |
95 |
96 |
97 |
98 | org.springframework.boot
99 | spring-boot-maven-plugin
100 |
101 |
102 | org.apache.maven.plugins
103 | maven-resources-plugin
104 | 2.6
105 |
106 |
107 | @
108 |
109 | false
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
--------------------------------------------------------------------------------
/spring-cloud-zuul/src/main/java/com/chengbinbbs/distribute/queue/DistributedBlockingQueue.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs.distribute.queue;
2 |
3 | import org.apache.commons.lang.StringUtils;
4 | import org.apache.zookeeper.*;
5 | import org.apache.zookeeper.data.Stat;
6 | import org.slf4j.Logger;
7 | import org.slf4j.LoggerFactory;
8 |
9 | import java.io.IOException;
10 | import java.util.Arrays;
11 | import java.util.List;
12 | import java.util.concurrent.CountDownLatch;
13 |
14 | /**
15 | * 分布式先进先出阻塞队列
16 | *
17 | * @author zhangcb
18 | * @created 2017-05-27 16:32.
19 | */
20 | public class DistributedBlockingQueue {
21 | private final Logger logger = LoggerFactory.getLogger(DistributedBlockingQueue.class);
22 | private final int ZK_SESSION_TIMEOUT = 5000;
23 | private String root = "/queue-";
24 | private CountDownLatch countDownLatch;
25 |
26 | private ZooKeeper zooKeeper;
27 |
28 | public DistributedBlockingQueue(String address, String queueName) {
29 | if (StringUtils.isBlank(address)) {
30 | throw new RuntimeException("zookeeper address can not be empty!");
31 | }
32 | if (StringUtils.isBlank(queueName)) {
33 | throw new RuntimeException("queueName can not be empty!");
34 | }
35 | zooKeeper = connectServer(address);
36 | if (zooKeeper != null) {
37 | root += queueName;
38 | try {
39 | Stat stat = zooKeeper.exists(root, false);
40 | if (stat == null) {
41 | zooKeeper.create(root, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
42 | }
43 | } catch (KeeperException e) {
44 | e.printStackTrace();
45 | } catch (InterruptedException e) {
46 | e.printStackTrace();
47 | }
48 |
49 | }
50 |
51 | }
52 |
53 |
54 | public boolean put(byte[] data) throws KeeperException, InterruptedException {
55 | logger.info(Thread.currentThread().getName() + "put!!!");
56 | zooKeeper.create(root + "/queue_", data, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL);
57 | return true;
58 | }
59 |
60 |
61 | public byte[] tack() throws KeeperException, InterruptedException {
62 | while (true) {
63 | countDownLatch = new CountDownLatch(1);
64 | List list = zooKeeper.getChildren(root, new Watcher() {
65 | @Override
66 | public void process(WatchedEvent watchedEvent) {
67 | countDownLatch.countDown();
68 | }
69 | });
70 | if (list.size() == 0) {
71 | countDownLatch.await();
72 | } else {
73 | String[] nodes = list.toArray(new String[list.size()]);
74 | Arrays.sort(nodes);//从小到大排序
75 | for (String node : nodes) {
76 | try {
77 | byte[] data = zooKeeper.getData(root + "/" + node, false, null);
78 | zooKeeper.delete(root + "/" + node, -1);
79 | return data;
80 | } catch (KeeperException.NoNodeException e) {
81 | // Another client deleted the node first.
82 | }
83 | }
84 | }
85 | }
86 | }
87 |
88 | /**
89 | * 连接zookeeper服务器
90 | *
91 | * @param address
92 | * @return
93 | */
94 | private ZooKeeper connectServer(String address) {
95 | final CountDownLatch latch = new CountDownLatch(1);
96 | ZooKeeper zk = null;
97 | try {
98 | zk = new ZooKeeper(address, ZK_SESSION_TIMEOUT, new Watcher() {
99 | @Override
100 | public void process(WatchedEvent event) {
101 | if (event.getState() == Event.KeeperState.SyncConnected) {
102 | latch.countDown();
103 | }
104 | }
105 | });
106 | latch.await();
107 | } catch (IOException e) {
108 | logger.error("IOException", e);
109 | } catch (InterruptedException ex) {
110 | logger.error("InterruptedException", ex);
111 | }
112 | return zk;
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/spring-cloud-admin/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM http://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven2 Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
40 |
41 | @REM set %HOME% to equivalent of $HOME
42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
43 |
44 | @REM Execute a user defined script before this one
45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
49 | :skipRcPre
50 |
51 | @setlocal
52 |
53 | set ERROR_CODE=0
54 |
55 | @REM To isolate internal variables from possible post scripts, we use another setlocal
56 | @setlocal
57 |
58 | @REM ==== START VALIDATION ====
59 | if not "%JAVA_HOME%" == "" goto OkJHome
60 |
61 | echo.
62 | echo Error: JAVA_HOME not found in your environment. >&2
63 | echo Please set the JAVA_HOME variable in your environment to match the >&2
64 | echo location of your Java installation. >&2
65 | echo.
66 | goto error
67 |
68 | :OkJHome
69 | if exist "%JAVA_HOME%\bin\java.exe" goto init
70 |
71 | echo.
72 | echo Error: JAVA_HOME is set to an invalid directory. >&2
73 | echo JAVA_HOME = "%JAVA_HOME%" >&2
74 | echo Please set the JAVA_HOME variable in your environment to match the >&2
75 | echo location of your Java installation. >&2
76 | echo.
77 | goto error
78 |
79 | @REM ==== END VALIDATION ====
80 |
81 | :init
82 |
83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
84 | @REM Fallback to current working directory if not found.
85 |
86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
88 |
89 | set EXEC_DIR=%CD%
90 | set WDIR=%EXEC_DIR%
91 | :findBaseDir
92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
93 | cd ..
94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
95 | set WDIR=%CD%
96 | goto findBaseDir
97 |
98 | :baseDirFound
99 | set MAVEN_PROJECTBASEDIR=%WDIR%
100 | cd "%EXEC_DIR%"
101 | goto endDetectBaseDir
102 |
103 | :baseDirNotFound
104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
105 | cd "%EXEC_DIR%"
106 |
107 | :endDetectBaseDir
108 |
109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
110 |
111 | @setlocal EnableExtensions EnableDelayedExpansion
112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
114 |
115 | :endReadAdditionalConfig
116 |
117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
118 |
119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
121 |
122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
123 | if ERRORLEVEL 1 goto error
124 | goto end
125 |
126 | :error
127 | set ERROR_CODE=1
128 |
129 | :end
130 | @endlocal & set ERROR_CODE=%ERROR_CODE%
131 |
132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
136 | :skipRcPost
137 |
138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
140 |
141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
142 |
143 | exit /B %ERROR_CODE%
144 |
--------------------------------------------------------------------------------
/spring-cloud-config/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM http://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven2 Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
40 |
41 | @REM set %HOME% to equivalent of $HOME
42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
43 |
44 | @REM Execute a user defined script before this one
45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
49 | :skipRcPre
50 |
51 | @setlocal
52 |
53 | set ERROR_CODE=0
54 |
55 | @REM To isolate internal variables from possible post scripts, we use another setlocal
56 | @setlocal
57 |
58 | @REM ==== START VALIDATION ====
59 | if not "%JAVA_HOME%" == "" goto OkJHome
60 |
61 | echo.
62 | echo Error: JAVA_HOME not found in your environment. >&2
63 | echo Please set the JAVA_HOME variable in your environment to match the >&2
64 | echo location of your Java installation. >&2
65 | echo.
66 | goto error
67 |
68 | :OkJHome
69 | if exist "%JAVA_HOME%\bin\java.exe" goto init
70 |
71 | echo.
72 | echo Error: JAVA_HOME is set to an invalid directory. >&2
73 | echo JAVA_HOME = "%JAVA_HOME%" >&2
74 | echo Please set the JAVA_HOME variable in your environment to match the >&2
75 | echo location of your Java installation. >&2
76 | echo.
77 | goto error
78 |
79 | @REM ==== END VALIDATION ====
80 |
81 | :init
82 |
83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
84 | @REM Fallback to current working directory if not found.
85 |
86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
88 |
89 | set EXEC_DIR=%CD%
90 | set WDIR=%EXEC_DIR%
91 | :findBaseDir
92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
93 | cd ..
94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
95 | set WDIR=%CD%
96 | goto findBaseDir
97 |
98 | :baseDirFound
99 | set MAVEN_PROJECTBASEDIR=%WDIR%
100 | cd "%EXEC_DIR%"
101 | goto endDetectBaseDir
102 |
103 | :baseDirNotFound
104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
105 | cd "%EXEC_DIR%"
106 |
107 | :endDetectBaseDir
108 |
109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
110 |
111 | @setlocal EnableExtensions EnableDelayedExpansion
112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
114 |
115 | :endReadAdditionalConfig
116 |
117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
118 |
119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
121 |
122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
123 | if ERRORLEVEL 1 goto error
124 | goto end
125 |
126 | :error
127 | set ERROR_CODE=1
128 |
129 | :end
130 | @endlocal & set ERROR_CODE=%ERROR_CODE%
131 |
132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
136 | :skipRcPost
137 |
138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
140 |
141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
142 |
143 | exit /B %ERROR_CODE%
144 |
--------------------------------------------------------------------------------
/spring-cloud-eureka/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM http://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven2 Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
40 |
41 | @REM set %HOME% to equivalent of $HOME
42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
43 |
44 | @REM Execute a user defined script before this one
45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
49 | :skipRcPre
50 |
51 | @setlocal
52 |
53 | set ERROR_CODE=0
54 |
55 | @REM To isolate internal variables from possible post scripts, we use another setlocal
56 | @setlocal
57 |
58 | @REM ==== START VALIDATION ====
59 | if not "%JAVA_HOME%" == "" goto OkJHome
60 |
61 | echo.
62 | echo Error: JAVA_HOME not found in your environment. >&2
63 | echo Please set the JAVA_HOME variable in your environment to match the >&2
64 | echo location of your Java installation. >&2
65 | echo.
66 | goto error
67 |
68 | :OkJHome
69 | if exist "%JAVA_HOME%\bin\java.exe" goto init
70 |
71 | echo.
72 | echo Error: JAVA_HOME is set to an invalid directory. >&2
73 | echo JAVA_HOME = "%JAVA_HOME%" >&2
74 | echo Please set the JAVA_HOME variable in your environment to match the >&2
75 | echo location of your Java installation. >&2
76 | echo.
77 | goto error
78 |
79 | @REM ==== END VALIDATION ====
80 |
81 | :init
82 |
83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
84 | @REM Fallback to current working directory if not found.
85 |
86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
88 |
89 | set EXEC_DIR=%CD%
90 | set WDIR=%EXEC_DIR%
91 | :findBaseDir
92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
93 | cd ..
94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
95 | set WDIR=%CD%
96 | goto findBaseDir
97 |
98 | :baseDirFound
99 | set MAVEN_PROJECTBASEDIR=%WDIR%
100 | cd "%EXEC_DIR%"
101 | goto endDetectBaseDir
102 |
103 | :baseDirNotFound
104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
105 | cd "%EXEC_DIR%"
106 |
107 | :endDetectBaseDir
108 |
109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
110 |
111 | @setlocal EnableExtensions EnableDelayedExpansion
112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
114 |
115 | :endReadAdditionalConfig
116 |
117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
118 |
119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
121 |
122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
123 | if ERRORLEVEL 1 goto error
124 | goto end
125 |
126 | :error
127 | set ERROR_CODE=1
128 |
129 | :end
130 | @endlocal & set ERROR_CODE=%ERROR_CODE%
131 |
132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
136 | :skipRcPost
137 |
138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
140 |
141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
142 |
143 | exit /B %ERROR_CODE%
144 |
--------------------------------------------------------------------------------
/spring-cloud-feign/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM http://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven2 Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
40 |
41 | @REM set %HOME% to equivalent of $HOME
42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
43 |
44 | @REM Execute a user defined script before this one
45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
49 | :skipRcPre
50 |
51 | @setlocal
52 |
53 | set ERROR_CODE=0
54 |
55 | @REM To isolate internal variables from possible post scripts, we use another setlocal
56 | @setlocal
57 |
58 | @REM ==== START VALIDATION ====
59 | if not "%JAVA_HOME%" == "" goto OkJHome
60 |
61 | echo.
62 | echo Error: JAVA_HOME not found in your environment. >&2
63 | echo Please set the JAVA_HOME variable in your environment to match the >&2
64 | echo location of your Java installation. >&2
65 | echo.
66 | goto error
67 |
68 | :OkJHome
69 | if exist "%JAVA_HOME%\bin\java.exe" goto init
70 |
71 | echo.
72 | echo Error: JAVA_HOME is set to an invalid directory. >&2
73 | echo JAVA_HOME = "%JAVA_HOME%" >&2
74 | echo Please set the JAVA_HOME variable in your environment to match the >&2
75 | echo location of your Java installation. >&2
76 | echo.
77 | goto error
78 |
79 | @REM ==== END VALIDATION ====
80 |
81 | :init
82 |
83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
84 | @REM Fallback to current working directory if not found.
85 |
86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
88 |
89 | set EXEC_DIR=%CD%
90 | set WDIR=%EXEC_DIR%
91 | :findBaseDir
92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
93 | cd ..
94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
95 | set WDIR=%CD%
96 | goto findBaseDir
97 |
98 | :baseDirFound
99 | set MAVEN_PROJECTBASEDIR=%WDIR%
100 | cd "%EXEC_DIR%"
101 | goto endDetectBaseDir
102 |
103 | :baseDirNotFound
104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
105 | cd "%EXEC_DIR%"
106 |
107 | :endDetectBaseDir
108 |
109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
110 |
111 | @setlocal EnableExtensions EnableDelayedExpansion
112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
114 |
115 | :endReadAdditionalConfig
116 |
117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
118 |
119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
121 |
122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
123 | if ERRORLEVEL 1 goto error
124 | goto end
125 |
126 | :error
127 | set ERROR_CODE=1
128 |
129 | :end
130 | @endlocal & set ERROR_CODE=%ERROR_CODE%
131 |
132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
136 | :skipRcPost
137 |
138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
140 |
141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
142 |
143 | exit /B %ERROR_CODE%
144 |
--------------------------------------------------------------------------------
/spring-cloud-ribbon/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM http://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven2 Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
40 |
41 | @REM set %HOME% to equivalent of $HOME
42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
43 |
44 | @REM Execute a user defined script before this one
45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
49 | :skipRcPre
50 |
51 | @setlocal
52 |
53 | set ERROR_CODE=0
54 |
55 | @REM To isolate internal variables from possible post scripts, we use another setlocal
56 | @setlocal
57 |
58 | @REM ==== START VALIDATION ====
59 | if not "%JAVA_HOME%" == "" goto OkJHome
60 |
61 | echo.
62 | echo Error: JAVA_HOME not found in your environment. >&2
63 | echo Please set the JAVA_HOME variable in your environment to match the >&2
64 | echo location of your Java installation. >&2
65 | echo.
66 | goto error
67 |
68 | :OkJHome
69 | if exist "%JAVA_HOME%\bin\java.exe" goto init
70 |
71 | echo.
72 | echo Error: JAVA_HOME is set to an invalid directory. >&2
73 | echo JAVA_HOME = "%JAVA_HOME%" >&2
74 | echo Please set the JAVA_HOME variable in your environment to match the >&2
75 | echo location of your Java installation. >&2
76 | echo.
77 | goto error
78 |
79 | @REM ==== END VALIDATION ====
80 |
81 | :init
82 |
83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
84 | @REM Fallback to current working directory if not found.
85 |
86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
88 |
89 | set EXEC_DIR=%CD%
90 | set WDIR=%EXEC_DIR%
91 | :findBaseDir
92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
93 | cd ..
94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
95 | set WDIR=%CD%
96 | goto findBaseDir
97 |
98 | :baseDirFound
99 | set MAVEN_PROJECTBASEDIR=%WDIR%
100 | cd "%EXEC_DIR%"
101 | goto endDetectBaseDir
102 |
103 | :baseDirNotFound
104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
105 | cd "%EXEC_DIR%"
106 |
107 | :endDetectBaseDir
108 |
109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
110 |
111 | @setlocal EnableExtensions EnableDelayedExpansion
112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
114 |
115 | :endReadAdditionalConfig
116 |
117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
118 |
119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
121 |
122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
123 | if ERRORLEVEL 1 goto error
124 | goto end
125 |
126 | :error
127 | set ERROR_CODE=1
128 |
129 | :end
130 | @endlocal & set ERROR_CODE=%ERROR_CODE%
131 |
132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
136 | :skipRcPost
137 |
138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
140 |
141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
142 |
143 | exit /B %ERROR_CODE%
144 |
--------------------------------------------------------------------------------
/spring-cloud-turbine/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM http://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven2 Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
40 |
41 | @REM set %HOME% to equivalent of $HOME
42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
43 |
44 | @REM Execute a user defined script before this one
45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
49 | :skipRcPre
50 |
51 | @setlocal
52 |
53 | set ERROR_CODE=0
54 |
55 | @REM To isolate internal variables from possible post scripts, we use another setlocal
56 | @setlocal
57 |
58 | @REM ==== START VALIDATION ====
59 | if not "%JAVA_HOME%" == "" goto OkJHome
60 |
61 | echo.
62 | echo Error: JAVA_HOME not found in your environment. >&2
63 | echo Please set the JAVA_HOME variable in your environment to match the >&2
64 | echo location of your Java installation. >&2
65 | echo.
66 | goto error
67 |
68 | :OkJHome
69 | if exist "%JAVA_HOME%\bin\java.exe" goto init
70 |
71 | echo.
72 | echo Error: JAVA_HOME is set to an invalid directory. >&2
73 | echo JAVA_HOME = "%JAVA_HOME%" >&2
74 | echo Please set the JAVA_HOME variable in your environment to match the >&2
75 | echo location of your Java installation. >&2
76 | echo.
77 | goto error
78 |
79 | @REM ==== END VALIDATION ====
80 |
81 | :init
82 |
83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
84 | @REM Fallback to current working directory if not found.
85 |
86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
88 |
89 | set EXEC_DIR=%CD%
90 | set WDIR=%EXEC_DIR%
91 | :findBaseDir
92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
93 | cd ..
94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
95 | set WDIR=%CD%
96 | goto findBaseDir
97 |
98 | :baseDirFound
99 | set MAVEN_PROJECTBASEDIR=%WDIR%
100 | cd "%EXEC_DIR%"
101 | goto endDetectBaseDir
102 |
103 | :baseDirNotFound
104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
105 | cd "%EXEC_DIR%"
106 |
107 | :endDetectBaseDir
108 |
109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
110 |
111 | @setlocal EnableExtensions EnableDelayedExpansion
112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
114 |
115 | :endReadAdditionalConfig
116 |
117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
118 |
119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
121 |
122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
123 | if ERRORLEVEL 1 goto error
124 | goto end
125 |
126 | :error
127 | set ERROR_CODE=1
128 |
129 | :end
130 | @endlocal & set ERROR_CODE=%ERROR_CODE%
131 |
132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
136 | :skipRcPost
137 |
138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
140 |
141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
142 |
143 | exit /B %ERROR_CODE%
144 |
--------------------------------------------------------------------------------
/spring-cloud-zuul/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM http://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven2 Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
40 |
41 | @REM set %HOME% to equivalent of $HOME
42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
43 |
44 | @REM Execute a user defined script before this one
45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
49 | :skipRcPre
50 |
51 | @setlocal
52 |
53 | set ERROR_CODE=0
54 |
55 | @REM To isolate internal variables from possible post scripts, we use another setlocal
56 | @setlocal
57 |
58 | @REM ==== START VALIDATION ====
59 | if not "%JAVA_HOME%" == "" goto OkJHome
60 |
61 | echo.
62 | echo Error: JAVA_HOME not found in your environment. >&2
63 | echo Please set the JAVA_HOME variable in your environment to match the >&2
64 | echo location of your Java installation. >&2
65 | echo.
66 | goto error
67 |
68 | :OkJHome
69 | if exist "%JAVA_HOME%\bin\java.exe" goto init
70 |
71 | echo.
72 | echo Error: JAVA_HOME is set to an invalid directory. >&2
73 | echo JAVA_HOME = "%JAVA_HOME%" >&2
74 | echo Please set the JAVA_HOME variable in your environment to match the >&2
75 | echo location of your Java installation. >&2
76 | echo.
77 | goto error
78 |
79 | @REM ==== END VALIDATION ====
80 |
81 | :init
82 |
83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
84 | @REM Fallback to current working directory if not found.
85 |
86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
88 |
89 | set EXEC_DIR=%CD%
90 | set WDIR=%EXEC_DIR%
91 | :findBaseDir
92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
93 | cd ..
94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
95 | set WDIR=%CD%
96 | goto findBaseDir
97 |
98 | :baseDirFound
99 | set MAVEN_PROJECTBASEDIR=%WDIR%
100 | cd "%EXEC_DIR%"
101 | goto endDetectBaseDir
102 |
103 | :baseDirNotFound
104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
105 | cd "%EXEC_DIR%"
106 |
107 | :endDetectBaseDir
108 |
109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
110 |
111 | @setlocal EnableExtensions EnableDelayedExpansion
112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
114 |
115 | :endReadAdditionalConfig
116 |
117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
118 |
119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
121 |
122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
123 | if ERRORLEVEL 1 goto error
124 | goto end
125 |
126 | :error
127 | set ERROR_CODE=1
128 |
129 | :end
130 | @endlocal & set ERROR_CODE=%ERROR_CODE%
131 |
132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
136 | :skipRcPost
137 |
138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
140 |
141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
142 |
143 | exit /B %ERROR_CODE%
144 |
--------------------------------------------------------------------------------
/spring-cloud-userservice/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM http://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven2 Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
40 |
41 | @REM set %HOME% to equivalent of $HOME
42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
43 |
44 | @REM Execute a user defined script before this one
45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
49 | :skipRcPre
50 |
51 | @setlocal
52 |
53 | set ERROR_CODE=0
54 |
55 | @REM To isolate internal variables from possible post scripts, we use another setlocal
56 | @setlocal
57 |
58 | @REM ==== START VALIDATION ====
59 | if not "%JAVA_HOME%" == "" goto OkJHome
60 |
61 | echo.
62 | echo Error: JAVA_HOME not found in your environment. >&2
63 | echo Please set the JAVA_HOME variable in your environment to match the >&2
64 | echo location of your Java installation. >&2
65 | echo.
66 | goto error
67 |
68 | :OkJHome
69 | if exist "%JAVA_HOME%\bin\java.exe" goto init
70 |
71 | echo.
72 | echo Error: JAVA_HOME is set to an invalid directory. >&2
73 | echo JAVA_HOME = "%JAVA_HOME%" >&2
74 | echo Please set the JAVA_HOME variable in your environment to match the >&2
75 | echo location of your Java installation. >&2
76 | echo.
77 | goto error
78 |
79 | @REM ==== END VALIDATION ====
80 |
81 | :init
82 |
83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
84 | @REM Fallback to current working directory if not found.
85 |
86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
88 |
89 | set EXEC_DIR=%CD%
90 | set WDIR=%EXEC_DIR%
91 | :findBaseDir
92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
93 | cd ..
94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
95 | set WDIR=%CD%
96 | goto findBaseDir
97 |
98 | :baseDirFound
99 | set MAVEN_PROJECTBASEDIR=%WDIR%
100 | cd "%EXEC_DIR%"
101 | goto endDetectBaseDir
102 |
103 | :baseDirNotFound
104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
105 | cd "%EXEC_DIR%"
106 |
107 | :endDetectBaseDir
108 |
109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
110 |
111 | @setlocal EnableExtensions EnableDelayedExpansion
112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
114 |
115 | :endReadAdditionalConfig
116 |
117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
118 |
119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
121 |
122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
123 | if ERRORLEVEL 1 goto error
124 | goto end
125 |
126 | :error
127 | set ERROR_CODE=1
128 |
129 | :end
130 | @endlocal & set ERROR_CODE=%ERROR_CODE%
131 |
132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
136 | :skipRcPost
137 |
138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
140 |
141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
142 |
143 | exit /B %ERROR_CODE%
144 |
--------------------------------------------------------------------------------
/spring-cloud-config-client/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM http://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven2 Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
40 |
41 | @REM set %HOME% to equivalent of $HOME
42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
43 |
44 | @REM Execute a user defined script before this one
45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
49 | :skipRcPre
50 |
51 | @setlocal
52 |
53 | set ERROR_CODE=0
54 |
55 | @REM To isolate internal variables from possible post scripts, we use another setlocal
56 | @setlocal
57 |
58 | @REM ==== START VALIDATION ====
59 | if not "%JAVA_HOME%" == "" goto OkJHome
60 |
61 | echo.
62 | echo Error: JAVA_HOME not found in your environment. >&2
63 | echo Please set the JAVA_HOME variable in your environment to match the >&2
64 | echo location of your Java installation. >&2
65 | echo.
66 | goto error
67 |
68 | :OkJHome
69 | if exist "%JAVA_HOME%\bin\java.exe" goto init
70 |
71 | echo.
72 | echo Error: JAVA_HOME is set to an invalid directory. >&2
73 | echo JAVA_HOME = "%JAVA_HOME%" >&2
74 | echo Please set the JAVA_HOME variable in your environment to match the >&2
75 | echo location of your Java installation. >&2
76 | echo.
77 | goto error
78 |
79 | @REM ==== END VALIDATION ====
80 |
81 | :init
82 |
83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
84 | @REM Fallback to current working directory if not found.
85 |
86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
88 |
89 | set EXEC_DIR=%CD%
90 | set WDIR=%EXEC_DIR%
91 | :findBaseDir
92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
93 | cd ..
94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
95 | set WDIR=%CD%
96 | goto findBaseDir
97 |
98 | :baseDirFound
99 | set MAVEN_PROJECTBASEDIR=%WDIR%
100 | cd "%EXEC_DIR%"
101 | goto endDetectBaseDir
102 |
103 | :baseDirNotFound
104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
105 | cd "%EXEC_DIR%"
106 |
107 | :endDetectBaseDir
108 |
109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
110 |
111 | @setlocal EnableExtensions EnableDelayedExpansion
112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
114 |
115 | :endReadAdditionalConfig
116 |
117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
118 |
119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
121 |
122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
123 | if ERRORLEVEL 1 goto error
124 | goto end
125 |
126 | :error
127 | set ERROR_CODE=1
128 |
129 | :end
130 | @endlocal & set ERROR_CODE=%ERROR_CODE%
131 |
132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
136 | :skipRcPost
137 |
138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
140 |
141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
142 |
143 | exit /B %ERROR_CODE%
144 |
--------------------------------------------------------------------------------
/spring-cloud-hystrixDashboard/mvnw.cmd:
--------------------------------------------------------------------------------
1 | @REM ----------------------------------------------------------------------------
2 | @REM Licensed to the Apache Software Foundation (ASF) under one
3 | @REM or more contributor license agreements. See the NOTICE file
4 | @REM distributed with this work for additional information
5 | @REM regarding copyright ownership. The ASF licenses this file
6 | @REM to you under the Apache License, Version 2.0 (the
7 | @REM "License"); you may not use this file except in compliance
8 | @REM with the License. You may obtain a copy of the License at
9 | @REM
10 | @REM http://www.apache.org/licenses/LICENSE-2.0
11 | @REM
12 | @REM Unless required by applicable law or agreed to in writing,
13 | @REM software distributed under the License is distributed on an
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | @REM KIND, either express or implied. See the License for the
16 | @REM specific language governing permissions and limitations
17 | @REM under the License.
18 | @REM ----------------------------------------------------------------------------
19 |
20 | @REM ----------------------------------------------------------------------------
21 | @REM Maven2 Start Up Batch script
22 | @REM
23 | @REM Required ENV vars:
24 | @REM JAVA_HOME - location of a JDK home dir
25 | @REM
26 | @REM Optional ENV vars
27 | @REM M2_HOME - location of maven2's installed home dir
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31 | @REM e.g. to debug Maven itself, use
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34 | @REM ----------------------------------------------------------------------------
35 |
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37 | @echo off
38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
40 |
41 | @REM set %HOME% to equivalent of $HOME
42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
43 |
44 | @REM Execute a user defined script before this one
45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending
47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
49 | :skipRcPre
50 |
51 | @setlocal
52 |
53 | set ERROR_CODE=0
54 |
55 | @REM To isolate internal variables from possible post scripts, we use another setlocal
56 | @setlocal
57 |
58 | @REM ==== START VALIDATION ====
59 | if not "%JAVA_HOME%" == "" goto OkJHome
60 |
61 | echo.
62 | echo Error: JAVA_HOME not found in your environment. >&2
63 | echo Please set the JAVA_HOME variable in your environment to match the >&2
64 | echo location of your Java installation. >&2
65 | echo.
66 | goto error
67 |
68 | :OkJHome
69 | if exist "%JAVA_HOME%\bin\java.exe" goto init
70 |
71 | echo.
72 | echo Error: JAVA_HOME is set to an invalid directory. >&2
73 | echo JAVA_HOME = "%JAVA_HOME%" >&2
74 | echo Please set the JAVA_HOME variable in your environment to match the >&2
75 | echo location of your Java installation. >&2
76 | echo.
77 | goto error
78 |
79 | @REM ==== END VALIDATION ====
80 |
81 | :init
82 |
83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
84 | @REM Fallback to current working directory if not found.
85 |
86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
88 |
89 | set EXEC_DIR=%CD%
90 | set WDIR=%EXEC_DIR%
91 | :findBaseDir
92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound
93 | cd ..
94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound
95 | set WDIR=%CD%
96 | goto findBaseDir
97 |
98 | :baseDirFound
99 | set MAVEN_PROJECTBASEDIR=%WDIR%
100 | cd "%EXEC_DIR%"
101 | goto endDetectBaseDir
102 |
103 | :baseDirNotFound
104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
105 | cd "%EXEC_DIR%"
106 |
107 | :endDetectBaseDir
108 |
109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
110 |
111 | @setlocal EnableExtensions EnableDelayedExpansion
112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
114 |
115 | :endReadAdditionalConfig
116 |
117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
118 |
119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
121 |
122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
123 | if ERRORLEVEL 1 goto error
124 | goto end
125 |
126 | :error
127 | set ERROR_CODE=1
128 |
129 | :end
130 | @endlocal & set ERROR_CODE=%ERROR_CODE%
131 |
132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending
134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
136 | :skipRcPost
137 |
138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause
140 |
141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
142 |
143 | exit /B %ERROR_CODE%
144 |
--------------------------------------------------------------------------------
/spring-cloud.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/spring-cloud-zuul/src/main/java/com/chengbinbbs/distribute/locks/DistributedLock.java:
--------------------------------------------------------------------------------
1 | package com.chengbinbbs.distribute.locks;
2 |
3 | import org.apache.commons.lang.StringUtils;
4 | import org.apache.zookeeper.*;
5 | import org.apache.zookeeper.data.Stat;
6 | import org.slf4j.Logger;
7 | import org.slf4j.LoggerFactory;
8 |
9 | import java.io.IOException;
10 | import java.util.Arrays;
11 | import java.util.List;
12 | import java.util.concurrent.CountDownLatch;
13 |
14 | /**
15 | * 基于Zookeeper设计的分布式锁
16 | *
17 | * @author zhangcb
18 | * @created 2017-05-27 16:31.
19 | */
20 | public class DistributedLock{
21 |
22 | private final Logger logger = LoggerFactory.getLogger(DistributedLock.class);
23 | private final int ZK_SESSION_TIMEOUT = 5000;
24 | private String root = "/lock-";
25 | private CountDownLatch countDownLatch = new CountDownLatch(1);
26 |
27 | private ZooKeeper zooKeeper;
28 | private String myPath;
29 |
30 |
31 | public DistributedLock(String address, String lockName) {
32 | if (StringUtils.isBlank(address)) {
33 | throw new RuntimeException("zookeeper address can not be empty!");
34 | }
35 | if (StringUtils.isBlank(lockName)) {
36 | throw new RuntimeException("lockName can not be empty!");
37 | }
38 | zooKeeper = connectServer(address);
39 | if (zooKeeper != null) {
40 | root += lockName;
41 | try {
42 | Stat stat = zooKeeper.exists(root, false);
43 | if (stat == null) {
44 | zooKeeper.create(root, new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
45 | }
46 | } catch (KeeperException e) {
47 | e.printStackTrace();
48 | } catch (InterruptedException e) {
49 | e.printStackTrace();
50 | }
51 |
52 | }
53 | }
54 |
55 | /**
56 | * 获取锁
57 | *
58 | * @throws KeeperException
59 | * @throws InterruptedException
60 | */
61 | public void lock() throws KeeperException, InterruptedException {
62 | logger.info(Thread.currentThread().getName() + " 开始等待锁");
63 | myPath = zooKeeper.create(root + "/lock_", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);
64 | judgeLock();
65 | }
66 |
67 | /**
68 | * 判断是否能够拥有该锁
69 | *
70 | * @throws KeeperException
71 | * @throws InterruptedException
72 | */
73 | private void judgeLock() throws KeeperException, InterruptedException {
74 | List list = zooKeeper.getChildren(root, false);
75 | String[] nodes = list.toArray(new String[list.size()]);
76 | Arrays.sort(nodes);//从小到大排序
77 | if (nodes.length > 0) {
78 | if (!myPath.equals(root + "/" + nodes[0])) {
79 | waitForLock(nodes[0]);
80 | } else {
81 | countDownLatch.countDown();
82 | }
83 | } else {
84 | countDownLatch.countDown();
85 | }
86 | }
87 |
88 |
89 | /**
90 | * 等待锁(写法1)
91 | *
92 | * @param nodePath
93 | * @throws InterruptedException
94 | * @throws KeeperException
95 | */
96 | private void waitForLock(String nodePath) throws InterruptedException, KeeperException {
97 | Stat stat = zooKeeper.exists(root + "/" + nodePath, false);
98 | if (stat == null) {
99 | judgeLock();
100 | } else {
101 | waitForLock(nodePath);
102 | }
103 | }
104 |
105 | /**
106 | * 等待锁(写法2)
107 | * 写法
108 | *
109 | * @param nodePath
110 | * @throws InterruptedException
111 | * @throws KeeperException
112 | */
113 | /* private void waitForLock(String nodePath) throws InterruptedException, KeeperException {
114 | final CountDownLatch latch=new CountDownLatch(1);
115 | Stat stat = zooKeeper.exists(root + "/" + nodePath, new Watcher() {
116 | @Override
117 | public void process(WatchedEvent watchedEvent) {
118 | latch.countDown();
119 | }
120 | });
121 | if (stat == null) {
122 | judgeLock();
123 | } else {
124 | latch.await();
125 | judgeLock();
126 | }
127 | }*/
128 |
129 |
130 | /**
131 | * 释放锁
132 | */
133 | public void unlock() {
134 | if (StringUtils.isEmpty(myPath)) {
135 | logger.error("no need to unlock!");
136 | }
137 | logger.info(Thread.currentThread().getName() + " 释放锁!!!");
138 | try {
139 | zooKeeper.delete(myPath, -1);
140 | } catch (InterruptedException e) {
141 | e.printStackTrace();
142 | } catch (KeeperException e) {
143 | e.printStackTrace();
144 | }
145 | }
146 |
147 | /**
148 | * 尝试获得锁,能获得就立马获得锁并返回true,如果不能获得就立马返回false
149 | *
150 | * @return
151 | */
152 | public boolean tryLock() throws KeeperException, InterruptedException {
153 | myPath = zooKeeper.create(root + "/lock_", new byte[0], ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);
154 | List list = zooKeeper.getChildren(root, false);
155 | String[] nodes = list.toArray(new String[list.size()]);
156 | Arrays.sort(nodes);//从小到大排序
157 | if (myPath.equals(root + "/" + nodes[0])) {
158 | return true;
159 | } else {
160 | return false;
161 | }
162 | }
163 |
164 |
165 | /**
166 | * 连接zookeeper服务器
167 | *
168 | * @param address
169 | * @return
170 | */
171 | private ZooKeeper connectServer(String address) {
172 | final CountDownLatch latch = new CountDownLatch(1);
173 | ZooKeeper zk = null;
174 | try {
175 | zk = new ZooKeeper(address, ZK_SESSION_TIMEOUT, new Watcher() {
176 | @Override
177 | public void process(WatchedEvent event) {
178 | if (event.getState() == Event.KeeperState.SyncConnected) {
179 | latch.countDown();
180 | }
181 | }
182 | });
183 | latch.await();
184 | } catch (IOException e) {
185 | logger.error("IOException", e);
186 | } catch (InterruptedException ex) {
187 | logger.error("InterruptedException", ex);
188 | }
189 | return zk;
190 | }
191 |
192 |
193 | }
194 |
--------------------------------------------------------------------------------
/spring-cloud-admin/mvnw:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # ----------------------------------------------------------------------------
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 | # ----------------------------------------------------------------------------
20 |
21 | # ----------------------------------------------------------------------------
22 | # Maven2 Start Up Batch script
23 | #
24 | # Required ENV vars:
25 | # ------------------
26 | # JAVA_HOME - location of a JDK home dir
27 | #
28 | # Optional ENV vars
29 | # -----------------
30 | # M2_HOME - location of maven2's installed home dir
31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven
32 | # e.g. to debug Maven itself, use
33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files
35 | # ----------------------------------------------------------------------------
36 |
37 | if [ -z "$MAVEN_SKIP_RC" ] ; then
38 |
39 | if [ -f /etc/mavenrc ] ; then
40 | . /etc/mavenrc
41 | fi
42 |
43 | if [ -f "$HOME/.mavenrc" ] ; then
44 | . "$HOME/.mavenrc"
45 | fi
46 |
47 | fi
48 |
49 | # OS specific support. $var _must_ be set to either true or false.
50 | cygwin=false;
51 | darwin=false;
52 | mingw=false
53 | case "`uname`" in
54 | CYGWIN*) cygwin=true ;;
55 | MINGW*) mingw=true;;
56 | Darwin*) darwin=true
57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
59 | if [ -z "$JAVA_HOME" ]; then
60 | if [ -x "/usr/libexec/java_home" ]; then
61 | export JAVA_HOME="`/usr/libexec/java_home`"
62 | else
63 | export JAVA_HOME="/Library/Java/Home"
64 | fi
65 | fi
66 | ;;
67 | esac
68 |
69 | if [ -z "$JAVA_HOME" ] ; then
70 | if [ -r /etc/gentoo-release ] ; then
71 | JAVA_HOME=`java-config --jre-home`
72 | fi
73 | fi
74 |
75 | if [ -z "$M2_HOME" ] ; then
76 | ## resolve links - $0 may be a link to maven's home
77 | PRG="$0"
78 |
79 | # need this for relative symlinks
80 | while [ -h "$PRG" ] ; do
81 | ls=`ls -ld "$PRG"`
82 | link=`expr "$ls" : '.*-> \(.*\)$'`
83 | if expr "$link" : '/.*' > /dev/null; then
84 | PRG="$link"
85 | else
86 | PRG="`dirname "$PRG"`/$link"
87 | fi
88 | done
89 |
90 | saveddir=`pwd`
91 |
92 | M2_HOME=`dirname "$PRG"`/..
93 |
94 | # make it fully qualified
95 | M2_HOME=`cd "$M2_HOME" && pwd`
96 |
97 | cd "$saveddir"
98 | # echo Using m2 at $M2_HOME
99 | fi
100 |
101 | # For Cygwin, ensure paths are in UNIX format before anything is touched
102 | if $cygwin ; then
103 | [ -n "$M2_HOME" ] &&
104 | M2_HOME=`cygpath --unix "$M2_HOME"`
105 | [ -n "$JAVA_HOME" ] &&
106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
107 | [ -n "$CLASSPATH" ] &&
108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
109 | fi
110 |
111 | # For Migwn, ensure paths are in UNIX format before anything is touched
112 | if $mingw ; then
113 | [ -n "$M2_HOME" ] &&
114 | M2_HOME="`(cd "$M2_HOME"; pwd)`"
115 | [ -n "$JAVA_HOME" ] &&
116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
117 | # TODO classpath?
118 | fi
119 |
120 | if [ -z "$JAVA_HOME" ]; then
121 | javaExecutable="`which javac`"
122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
123 | # readlink(1) is not available as standard on Solaris 10.
124 | readLink=`which readlink`
125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
126 | if $darwin ; then
127 | javaHome="`dirname \"$javaExecutable\"`"
128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
129 | else
130 | javaExecutable="`readlink -f \"$javaExecutable\"`"
131 | fi
132 | javaHome="`dirname \"$javaExecutable\"`"
133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'`
134 | JAVA_HOME="$javaHome"
135 | export JAVA_HOME
136 | fi
137 | fi
138 | fi
139 |
140 | if [ -z "$JAVACMD" ] ; then
141 | if [ -n "$JAVA_HOME" ] ; then
142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
143 | # IBM's JDK on AIX uses strange locations for the executables
144 | JAVACMD="$JAVA_HOME/jre/sh/java"
145 | else
146 | JAVACMD="$JAVA_HOME/bin/java"
147 | fi
148 | else
149 | JAVACMD="`which java`"
150 | fi
151 | fi
152 |
153 | if [ ! -x "$JAVACMD" ] ; then
154 | echo "Error: JAVA_HOME is not defined correctly." >&2
155 | echo " We cannot execute $JAVACMD" >&2
156 | exit 1
157 | fi
158 |
159 | if [ -z "$JAVA_HOME" ] ; then
160 | echo "Warning: JAVA_HOME environment variable is not set."
161 | fi
162 |
163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
164 |
165 | # traverses directory structure from process work directory to filesystem root
166 | # first directory with .mvn subdirectory is considered project base directory
167 | find_maven_basedir() {
168 |
169 | if [ -z "$1" ]
170 | then
171 | echo "Path not specified to find_maven_basedir"
172 | return 1
173 | fi
174 |
175 | basedir="$1"
176 | wdir="$1"
177 | while [ "$wdir" != '/' ] ; do
178 | if [ -d "$wdir"/.mvn ] ; then
179 | basedir=$wdir
180 | break
181 | fi
182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc)
183 | if [ -d "${wdir}" ]; then
184 | wdir=`cd "$wdir/.."; pwd`
185 | fi
186 | # end of workaround
187 | done
188 | echo "${basedir}"
189 | }
190 |
191 | # concatenates all lines of a file
192 | concat_lines() {
193 | if [ -f "$1" ]; then
194 | echo "$(tr -s '\n' ' ' < "$1")"
195 | fi
196 | }
197 |
198 | BASE_DIR=`find_maven_basedir "$(pwd)"`
199 | if [ -z "$BASE_DIR" ]; then
200 | exit 1;
201 | fi
202 |
203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
204 | echo $MAVEN_PROJECTBASEDIR
205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
206 |
207 | # For Cygwin, switch paths to Windows format before running java
208 | if $cygwin; then
209 | [ -n "$M2_HOME" ] &&
210 | M2_HOME=`cygpath --path --windows "$M2_HOME"`
211 | [ -n "$JAVA_HOME" ] &&
212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
213 | [ -n "$CLASSPATH" ] &&
214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
215 | [ -n "$MAVEN_PROJECTBASEDIR" ] &&
216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
217 | fi
218 |
219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
220 |
221 | exec "$JAVACMD" \
222 | $MAVEN_OPTS \
223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
226 |
--------------------------------------------------------------------------------
/spring-cloud-feign/mvnw:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # ----------------------------------------------------------------------------
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 | # ----------------------------------------------------------------------------
20 |
21 | # ----------------------------------------------------------------------------
22 | # Maven2 Start Up Batch script
23 | #
24 | # Required ENV vars:
25 | # ------------------
26 | # JAVA_HOME - location of a JDK home dir
27 | #
28 | # Optional ENV vars
29 | # -----------------
30 | # M2_HOME - location of maven2's installed home dir
31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven
32 | # e.g. to debug Maven itself, use
33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files
35 | # ----------------------------------------------------------------------------
36 |
37 | if [ -z "$MAVEN_SKIP_RC" ] ; then
38 |
39 | if [ -f /etc/mavenrc ] ; then
40 | . /etc/mavenrc
41 | fi
42 |
43 | if [ -f "$HOME/.mavenrc" ] ; then
44 | . "$HOME/.mavenrc"
45 | fi
46 |
47 | fi
48 |
49 | # OS specific support. $var _must_ be set to either true or false.
50 | cygwin=false;
51 | darwin=false;
52 | mingw=false
53 | case "`uname`" in
54 | CYGWIN*) cygwin=true ;;
55 | MINGW*) mingw=true;;
56 | Darwin*) darwin=true
57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
59 | if [ -z "$JAVA_HOME" ]; then
60 | if [ -x "/usr/libexec/java_home" ]; then
61 | export JAVA_HOME="`/usr/libexec/java_home`"
62 | else
63 | export JAVA_HOME="/Library/Java/Home"
64 | fi
65 | fi
66 | ;;
67 | esac
68 |
69 | if [ -z "$JAVA_HOME" ] ; then
70 | if [ -r /etc/gentoo-release ] ; then
71 | JAVA_HOME=`java-config --jre-home`
72 | fi
73 | fi
74 |
75 | if [ -z "$M2_HOME" ] ; then
76 | ## resolve links - $0 may be a link to maven's home
77 | PRG="$0"
78 |
79 | # need this for relative symlinks
80 | while [ -h "$PRG" ] ; do
81 | ls=`ls -ld "$PRG"`
82 | link=`expr "$ls" : '.*-> \(.*\)$'`
83 | if expr "$link" : '/.*' > /dev/null; then
84 | PRG="$link"
85 | else
86 | PRG="`dirname "$PRG"`/$link"
87 | fi
88 | done
89 |
90 | saveddir=`pwd`
91 |
92 | M2_HOME=`dirname "$PRG"`/..
93 |
94 | # make it fully qualified
95 | M2_HOME=`cd "$M2_HOME" && pwd`
96 |
97 | cd "$saveddir"
98 | # echo Using m2 at $M2_HOME
99 | fi
100 |
101 | # For Cygwin, ensure paths are in UNIX format before anything is touched
102 | if $cygwin ; then
103 | [ -n "$M2_HOME" ] &&
104 | M2_HOME=`cygpath --unix "$M2_HOME"`
105 | [ -n "$JAVA_HOME" ] &&
106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
107 | [ -n "$CLASSPATH" ] &&
108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
109 | fi
110 |
111 | # For Migwn, ensure paths are in UNIX format before anything is touched
112 | if $mingw ; then
113 | [ -n "$M2_HOME" ] &&
114 | M2_HOME="`(cd "$M2_HOME"; pwd)`"
115 | [ -n "$JAVA_HOME" ] &&
116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
117 | # TODO classpath?
118 | fi
119 |
120 | if [ -z "$JAVA_HOME" ]; then
121 | javaExecutable="`which javac`"
122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
123 | # readlink(1) is not available as standard on Solaris 10.
124 | readLink=`which readlink`
125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
126 | if $darwin ; then
127 | javaHome="`dirname \"$javaExecutable\"`"
128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
129 | else
130 | javaExecutable="`readlink -f \"$javaExecutable\"`"
131 | fi
132 | javaHome="`dirname \"$javaExecutable\"`"
133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'`
134 | JAVA_HOME="$javaHome"
135 | export JAVA_HOME
136 | fi
137 | fi
138 | fi
139 |
140 | if [ -z "$JAVACMD" ] ; then
141 | if [ -n "$JAVA_HOME" ] ; then
142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
143 | # IBM's JDK on AIX uses strange locations for the executables
144 | JAVACMD="$JAVA_HOME/jre/sh/java"
145 | else
146 | JAVACMD="$JAVA_HOME/bin/java"
147 | fi
148 | else
149 | JAVACMD="`which java`"
150 | fi
151 | fi
152 |
153 | if [ ! -x "$JAVACMD" ] ; then
154 | echo "Error: JAVA_HOME is not defined correctly." >&2
155 | echo " We cannot execute $JAVACMD" >&2
156 | exit 1
157 | fi
158 |
159 | if [ -z "$JAVA_HOME" ] ; then
160 | echo "Warning: JAVA_HOME environment variable is not set."
161 | fi
162 |
163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
164 |
165 | # traverses directory structure from process work directory to filesystem root
166 | # first directory with .mvn subdirectory is considered project base directory
167 | find_maven_basedir() {
168 |
169 | if [ -z "$1" ]
170 | then
171 | echo "Path not specified to find_maven_basedir"
172 | return 1
173 | fi
174 |
175 | basedir="$1"
176 | wdir="$1"
177 | while [ "$wdir" != '/' ] ; do
178 | if [ -d "$wdir"/.mvn ] ; then
179 | basedir=$wdir
180 | break
181 | fi
182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc)
183 | if [ -d "${wdir}" ]; then
184 | wdir=`cd "$wdir/.."; pwd`
185 | fi
186 | # end of workaround
187 | done
188 | echo "${basedir}"
189 | }
190 |
191 | # concatenates all lines of a file
192 | concat_lines() {
193 | if [ -f "$1" ]; then
194 | echo "$(tr -s '\n' ' ' < "$1")"
195 | fi
196 | }
197 |
198 | BASE_DIR=`find_maven_basedir "$(pwd)"`
199 | if [ -z "$BASE_DIR" ]; then
200 | exit 1;
201 | fi
202 |
203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
204 | echo $MAVEN_PROJECTBASEDIR
205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
206 |
207 | # For Cygwin, switch paths to Windows format before running java
208 | if $cygwin; then
209 | [ -n "$M2_HOME" ] &&
210 | M2_HOME=`cygpath --path --windows "$M2_HOME"`
211 | [ -n "$JAVA_HOME" ] &&
212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
213 | [ -n "$CLASSPATH" ] &&
214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
215 | [ -n "$MAVEN_PROJECTBASEDIR" ] &&
216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
217 | fi
218 |
219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
220 |
221 | exec "$JAVACMD" \
222 | $MAVEN_OPTS \
223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
226 |
--------------------------------------------------------------------------------
/spring-cloud-zuul/mvnw:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # ----------------------------------------------------------------------------
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 | # ----------------------------------------------------------------------------
20 |
21 | # ----------------------------------------------------------------------------
22 | # Maven2 Start Up Batch script
23 | #
24 | # Required ENV vars:
25 | # ------------------
26 | # JAVA_HOME - location of a JDK home dir
27 | #
28 | # Optional ENV vars
29 | # -----------------
30 | # M2_HOME - location of maven2's installed home dir
31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven
32 | # e.g. to debug Maven itself, use
33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files
35 | # ----------------------------------------------------------------------------
36 |
37 | if [ -z "$MAVEN_SKIP_RC" ] ; then
38 |
39 | if [ -f /etc/mavenrc ] ; then
40 | . /etc/mavenrc
41 | fi
42 |
43 | if [ -f "$HOME/.mavenrc" ] ; then
44 | . "$HOME/.mavenrc"
45 | fi
46 |
47 | fi
48 |
49 | # OS specific support. $var _must_ be set to either true or false.
50 | cygwin=false;
51 | darwin=false;
52 | mingw=false
53 | case "`uname`" in
54 | CYGWIN*) cygwin=true ;;
55 | MINGW*) mingw=true;;
56 | Darwin*) darwin=true
57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
59 | if [ -z "$JAVA_HOME" ]; then
60 | if [ -x "/usr/libexec/java_home" ]; then
61 | export JAVA_HOME="`/usr/libexec/java_home`"
62 | else
63 | export JAVA_HOME="/Library/Java/Home"
64 | fi
65 | fi
66 | ;;
67 | esac
68 |
69 | if [ -z "$JAVA_HOME" ] ; then
70 | if [ -r /etc/gentoo-release ] ; then
71 | JAVA_HOME=`java-config --jre-home`
72 | fi
73 | fi
74 |
75 | if [ -z "$M2_HOME" ] ; then
76 | ## resolve links - $0 may be a link to maven's home
77 | PRG="$0"
78 |
79 | # need this for relative symlinks
80 | while [ -h "$PRG" ] ; do
81 | ls=`ls -ld "$PRG"`
82 | link=`expr "$ls" : '.*-> \(.*\)$'`
83 | if expr "$link" : '/.*' > /dev/null; then
84 | PRG="$link"
85 | else
86 | PRG="`dirname "$PRG"`/$link"
87 | fi
88 | done
89 |
90 | saveddir=`pwd`
91 |
92 | M2_HOME=`dirname "$PRG"`/..
93 |
94 | # make it fully qualified
95 | M2_HOME=`cd "$M2_HOME" && pwd`
96 |
97 | cd "$saveddir"
98 | # echo Using m2 at $M2_HOME
99 | fi
100 |
101 | # For Cygwin, ensure paths are in UNIX format before anything is touched
102 | if $cygwin ; then
103 | [ -n "$M2_HOME" ] &&
104 | M2_HOME=`cygpath --unix "$M2_HOME"`
105 | [ -n "$JAVA_HOME" ] &&
106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
107 | [ -n "$CLASSPATH" ] &&
108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
109 | fi
110 |
111 | # For Migwn, ensure paths are in UNIX format before anything is touched
112 | if $mingw ; then
113 | [ -n "$M2_HOME" ] &&
114 | M2_HOME="`(cd "$M2_HOME"; pwd)`"
115 | [ -n "$JAVA_HOME" ] &&
116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
117 | # TODO classpath?
118 | fi
119 |
120 | if [ -z "$JAVA_HOME" ]; then
121 | javaExecutable="`which javac`"
122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
123 | # readlink(1) is not available as standard on Solaris 10.
124 | readLink=`which readlink`
125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
126 | if $darwin ; then
127 | javaHome="`dirname \"$javaExecutable\"`"
128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
129 | else
130 | javaExecutable="`readlink -f \"$javaExecutable\"`"
131 | fi
132 | javaHome="`dirname \"$javaExecutable\"`"
133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'`
134 | JAVA_HOME="$javaHome"
135 | export JAVA_HOME
136 | fi
137 | fi
138 | fi
139 |
140 | if [ -z "$JAVACMD" ] ; then
141 | if [ -n "$JAVA_HOME" ] ; then
142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
143 | # IBM's JDK on AIX uses strange locations for the executables
144 | JAVACMD="$JAVA_HOME/jre/sh/java"
145 | else
146 | JAVACMD="$JAVA_HOME/bin/java"
147 | fi
148 | else
149 | JAVACMD="`which java`"
150 | fi
151 | fi
152 |
153 | if [ ! -x "$JAVACMD" ] ; then
154 | echo "Error: JAVA_HOME is not defined correctly." >&2
155 | echo " We cannot execute $JAVACMD" >&2
156 | exit 1
157 | fi
158 |
159 | if [ -z "$JAVA_HOME" ] ; then
160 | echo "Warning: JAVA_HOME environment variable is not set."
161 | fi
162 |
163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
164 |
165 | # traverses directory structure from process work directory to filesystem root
166 | # first directory with .mvn subdirectory is considered project base directory
167 | find_maven_basedir() {
168 |
169 | if [ -z "$1" ]
170 | then
171 | echo "Path not specified to find_maven_basedir"
172 | return 1
173 | fi
174 |
175 | basedir="$1"
176 | wdir="$1"
177 | while [ "$wdir" != '/' ] ; do
178 | if [ -d "$wdir"/.mvn ] ; then
179 | basedir=$wdir
180 | break
181 | fi
182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc)
183 | if [ -d "${wdir}" ]; then
184 | wdir=`cd "$wdir/.."; pwd`
185 | fi
186 | # end of workaround
187 | done
188 | echo "${basedir}"
189 | }
190 |
191 | # concatenates all lines of a file
192 | concat_lines() {
193 | if [ -f "$1" ]; then
194 | echo "$(tr -s '\n' ' ' < "$1")"
195 | fi
196 | }
197 |
198 | BASE_DIR=`find_maven_basedir "$(pwd)"`
199 | if [ -z "$BASE_DIR" ]; then
200 | exit 1;
201 | fi
202 |
203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
204 | echo $MAVEN_PROJECTBASEDIR
205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
206 |
207 | # For Cygwin, switch paths to Windows format before running java
208 | if $cygwin; then
209 | [ -n "$M2_HOME" ] &&
210 | M2_HOME=`cygpath --path --windows "$M2_HOME"`
211 | [ -n "$JAVA_HOME" ] &&
212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
213 | [ -n "$CLASSPATH" ] &&
214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
215 | [ -n "$MAVEN_PROJECTBASEDIR" ] &&
216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
217 | fi
218 |
219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
220 |
221 | exec "$JAVACMD" \
222 | $MAVEN_OPTS \
223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
226 |
--------------------------------------------------------------------------------
/spring-cloud-config/mvnw:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # ----------------------------------------------------------------------------
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 | # ----------------------------------------------------------------------------
20 |
21 | # ----------------------------------------------------------------------------
22 | # Maven2 Start Up Batch script
23 | #
24 | # Required ENV vars:
25 | # ------------------
26 | # JAVA_HOME - location of a JDK home dir
27 | #
28 | # Optional ENV vars
29 | # -----------------
30 | # M2_HOME - location of maven2's installed home dir
31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven
32 | # e.g. to debug Maven itself, use
33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files
35 | # ----------------------------------------------------------------------------
36 |
37 | if [ -z "$MAVEN_SKIP_RC" ] ; then
38 |
39 | if [ -f /etc/mavenrc ] ; then
40 | . /etc/mavenrc
41 | fi
42 |
43 | if [ -f "$HOME/.mavenrc" ] ; then
44 | . "$HOME/.mavenrc"
45 | fi
46 |
47 | fi
48 |
49 | # OS specific support. $var _must_ be set to either true or false.
50 | cygwin=false;
51 | darwin=false;
52 | mingw=false
53 | case "`uname`" in
54 | CYGWIN*) cygwin=true ;;
55 | MINGW*) mingw=true;;
56 | Darwin*) darwin=true
57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
59 | if [ -z "$JAVA_HOME" ]; then
60 | if [ -x "/usr/libexec/java_home" ]; then
61 | export JAVA_HOME="`/usr/libexec/java_home`"
62 | else
63 | export JAVA_HOME="/Library/Java/Home"
64 | fi
65 | fi
66 | ;;
67 | esac
68 |
69 | if [ -z "$JAVA_HOME" ] ; then
70 | if [ -r /etc/gentoo-release ] ; then
71 | JAVA_HOME=`java-config --jre-home`
72 | fi
73 | fi
74 |
75 | if [ -z "$M2_HOME" ] ; then
76 | ## resolve links - $0 may be a link to maven's home
77 | PRG="$0"
78 |
79 | # need this for relative symlinks
80 | while [ -h "$PRG" ] ; do
81 | ls=`ls -ld "$PRG"`
82 | link=`expr "$ls" : '.*-> \(.*\)$'`
83 | if expr "$link" : '/.*' > /dev/null; then
84 | PRG="$link"
85 | else
86 | PRG="`dirname "$PRG"`/$link"
87 | fi
88 | done
89 |
90 | saveddir=`pwd`
91 |
92 | M2_HOME=`dirname "$PRG"`/..
93 |
94 | # make it fully qualified
95 | M2_HOME=`cd "$M2_HOME" && pwd`
96 |
97 | cd "$saveddir"
98 | # echo Using m2 at $M2_HOME
99 | fi
100 |
101 | # For Cygwin, ensure paths are in UNIX format before anything is touched
102 | if $cygwin ; then
103 | [ -n "$M2_HOME" ] &&
104 | M2_HOME=`cygpath --unix "$M2_HOME"`
105 | [ -n "$JAVA_HOME" ] &&
106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
107 | [ -n "$CLASSPATH" ] &&
108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
109 | fi
110 |
111 | # For Migwn, ensure paths are in UNIX format before anything is touched
112 | if $mingw ; then
113 | [ -n "$M2_HOME" ] &&
114 | M2_HOME="`(cd "$M2_HOME"; pwd)`"
115 | [ -n "$JAVA_HOME" ] &&
116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
117 | # TODO classpath?
118 | fi
119 |
120 | if [ -z "$JAVA_HOME" ]; then
121 | javaExecutable="`which javac`"
122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
123 | # readlink(1) is not available as standard on Solaris 10.
124 | readLink=`which readlink`
125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
126 | if $darwin ; then
127 | javaHome="`dirname \"$javaExecutable\"`"
128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
129 | else
130 | javaExecutable="`readlink -f \"$javaExecutable\"`"
131 | fi
132 | javaHome="`dirname \"$javaExecutable\"`"
133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'`
134 | JAVA_HOME="$javaHome"
135 | export JAVA_HOME
136 | fi
137 | fi
138 | fi
139 |
140 | if [ -z "$JAVACMD" ] ; then
141 | if [ -n "$JAVA_HOME" ] ; then
142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
143 | # IBM's JDK on AIX uses strange locations for the executables
144 | JAVACMD="$JAVA_HOME/jre/sh/java"
145 | else
146 | JAVACMD="$JAVA_HOME/bin/java"
147 | fi
148 | else
149 | JAVACMD="`which java`"
150 | fi
151 | fi
152 |
153 | if [ ! -x "$JAVACMD" ] ; then
154 | echo "Error: JAVA_HOME is not defined correctly." >&2
155 | echo " We cannot execute $JAVACMD" >&2
156 | exit 1
157 | fi
158 |
159 | if [ -z "$JAVA_HOME" ] ; then
160 | echo "Warning: JAVA_HOME environment variable is not set."
161 | fi
162 |
163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
164 |
165 | # traverses directory structure from process work directory to filesystem root
166 | # first directory with .mvn subdirectory is considered project base directory
167 | find_maven_basedir() {
168 |
169 | if [ -z "$1" ]
170 | then
171 | echo "Path not specified to find_maven_basedir"
172 | return 1
173 | fi
174 |
175 | basedir="$1"
176 | wdir="$1"
177 | while [ "$wdir" != '/' ] ; do
178 | if [ -d "$wdir"/.mvn ] ; then
179 | basedir=$wdir
180 | break
181 | fi
182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc)
183 | if [ -d "${wdir}" ]; then
184 | wdir=`cd "$wdir/.."; pwd`
185 | fi
186 | # end of workaround
187 | done
188 | echo "${basedir}"
189 | }
190 |
191 | # concatenates all lines of a file
192 | concat_lines() {
193 | if [ -f "$1" ]; then
194 | echo "$(tr -s '\n' ' ' < "$1")"
195 | fi
196 | }
197 |
198 | BASE_DIR=`find_maven_basedir "$(pwd)"`
199 | if [ -z "$BASE_DIR" ]; then
200 | exit 1;
201 | fi
202 |
203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
204 | echo $MAVEN_PROJECTBASEDIR
205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
206 |
207 | # For Cygwin, switch paths to Windows format before running java
208 | if $cygwin; then
209 | [ -n "$M2_HOME" ] &&
210 | M2_HOME=`cygpath --path --windows "$M2_HOME"`
211 | [ -n "$JAVA_HOME" ] &&
212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
213 | [ -n "$CLASSPATH" ] &&
214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
215 | [ -n "$MAVEN_PROJECTBASEDIR" ] &&
216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
217 | fi
218 |
219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
220 |
221 | exec "$JAVACMD" \
222 | $MAVEN_OPTS \
223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
226 |
--------------------------------------------------------------------------------
/spring-cloud-eureka/mvnw:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # ----------------------------------------------------------------------------
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 | # ----------------------------------------------------------------------------
20 |
21 | # ----------------------------------------------------------------------------
22 | # Maven2 Start Up Batch script
23 | #
24 | # Required ENV vars:
25 | # ------------------
26 | # JAVA_HOME - location of a JDK home dir
27 | #
28 | # Optional ENV vars
29 | # -----------------
30 | # M2_HOME - location of maven2's installed home dir
31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven
32 | # e.g. to debug Maven itself, use
33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files
35 | # ----------------------------------------------------------------------------
36 |
37 | if [ -z "$MAVEN_SKIP_RC" ] ; then
38 |
39 | if [ -f /etc/mavenrc ] ; then
40 | . /etc/mavenrc
41 | fi
42 |
43 | if [ -f "$HOME/.mavenrc" ] ; then
44 | . "$HOME/.mavenrc"
45 | fi
46 |
47 | fi
48 |
49 | # OS specific support. $var _must_ be set to either true or false.
50 | cygwin=false;
51 | darwin=false;
52 | mingw=false
53 | case "`uname`" in
54 | CYGWIN*) cygwin=true ;;
55 | MINGW*) mingw=true;;
56 | Darwin*) darwin=true
57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
59 | if [ -z "$JAVA_HOME" ]; then
60 | if [ -x "/usr/libexec/java_home" ]; then
61 | export JAVA_HOME="`/usr/libexec/java_home`"
62 | else
63 | export JAVA_HOME="/Library/Java/Home"
64 | fi
65 | fi
66 | ;;
67 | esac
68 |
69 | if [ -z "$JAVA_HOME" ] ; then
70 | if [ -r /etc/gentoo-release ] ; then
71 | JAVA_HOME=`java-config --jre-home`
72 | fi
73 | fi
74 |
75 | if [ -z "$M2_HOME" ] ; then
76 | ## resolve links - $0 may be a link to maven's home
77 | PRG="$0"
78 |
79 | # need this for relative symlinks
80 | while [ -h "$PRG" ] ; do
81 | ls=`ls -ld "$PRG"`
82 | link=`expr "$ls" : '.*-> \(.*\)$'`
83 | if expr "$link" : '/.*' > /dev/null; then
84 | PRG="$link"
85 | else
86 | PRG="`dirname "$PRG"`/$link"
87 | fi
88 | done
89 |
90 | saveddir=`pwd`
91 |
92 | M2_HOME=`dirname "$PRG"`/..
93 |
94 | # make it fully qualified
95 | M2_HOME=`cd "$M2_HOME" && pwd`
96 |
97 | cd "$saveddir"
98 | # echo Using m2 at $M2_HOME
99 | fi
100 |
101 | # For Cygwin, ensure paths are in UNIX format before anything is touched
102 | if $cygwin ; then
103 | [ -n "$M2_HOME" ] &&
104 | M2_HOME=`cygpath --unix "$M2_HOME"`
105 | [ -n "$JAVA_HOME" ] &&
106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
107 | [ -n "$CLASSPATH" ] &&
108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
109 | fi
110 |
111 | # For Migwn, ensure paths are in UNIX format before anything is touched
112 | if $mingw ; then
113 | [ -n "$M2_HOME" ] &&
114 | M2_HOME="`(cd "$M2_HOME"; pwd)`"
115 | [ -n "$JAVA_HOME" ] &&
116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
117 | # TODO classpath?
118 | fi
119 |
120 | if [ -z "$JAVA_HOME" ]; then
121 | javaExecutable="`which javac`"
122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
123 | # readlink(1) is not available as standard on Solaris 10.
124 | readLink=`which readlink`
125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
126 | if $darwin ; then
127 | javaHome="`dirname \"$javaExecutable\"`"
128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
129 | else
130 | javaExecutable="`readlink -f \"$javaExecutable\"`"
131 | fi
132 | javaHome="`dirname \"$javaExecutable\"`"
133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'`
134 | JAVA_HOME="$javaHome"
135 | export JAVA_HOME
136 | fi
137 | fi
138 | fi
139 |
140 | if [ -z "$JAVACMD" ] ; then
141 | if [ -n "$JAVA_HOME" ] ; then
142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
143 | # IBM's JDK on AIX uses strange locations for the executables
144 | JAVACMD="$JAVA_HOME/jre/sh/java"
145 | else
146 | JAVACMD="$JAVA_HOME/bin/java"
147 | fi
148 | else
149 | JAVACMD="`which java`"
150 | fi
151 | fi
152 |
153 | if [ ! -x "$JAVACMD" ] ; then
154 | echo "Error: JAVA_HOME is not defined correctly." >&2
155 | echo " We cannot execute $JAVACMD" >&2
156 | exit 1
157 | fi
158 |
159 | if [ -z "$JAVA_HOME" ] ; then
160 | echo "Warning: JAVA_HOME environment variable is not set."
161 | fi
162 |
163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
164 |
165 | # traverses directory structure from process work directory to filesystem root
166 | # first directory with .mvn subdirectory is considered project base directory
167 | find_maven_basedir() {
168 |
169 | if [ -z "$1" ]
170 | then
171 | echo "Path not specified to find_maven_basedir"
172 | return 1
173 | fi
174 |
175 | basedir="$1"
176 | wdir="$1"
177 | while [ "$wdir" != '/' ] ; do
178 | if [ -d "$wdir"/.mvn ] ; then
179 | basedir=$wdir
180 | break
181 | fi
182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc)
183 | if [ -d "${wdir}" ]; then
184 | wdir=`cd "$wdir/.."; pwd`
185 | fi
186 | # end of workaround
187 | done
188 | echo "${basedir}"
189 | }
190 |
191 | # concatenates all lines of a file
192 | concat_lines() {
193 | if [ -f "$1" ]; then
194 | echo "$(tr -s '\n' ' ' < "$1")"
195 | fi
196 | }
197 |
198 | BASE_DIR=`find_maven_basedir "$(pwd)"`
199 | if [ -z "$BASE_DIR" ]; then
200 | exit 1;
201 | fi
202 |
203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
204 | echo $MAVEN_PROJECTBASEDIR
205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
206 |
207 | # For Cygwin, switch paths to Windows format before running java
208 | if $cygwin; then
209 | [ -n "$M2_HOME" ] &&
210 | M2_HOME=`cygpath --path --windows "$M2_HOME"`
211 | [ -n "$JAVA_HOME" ] &&
212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
213 | [ -n "$CLASSPATH" ] &&
214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
215 | [ -n "$MAVEN_PROJECTBASEDIR" ] &&
216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
217 | fi
218 |
219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
220 |
221 | exec "$JAVACMD" \
222 | $MAVEN_OPTS \
223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
226 |
--------------------------------------------------------------------------------
/spring-cloud-ribbon/mvnw:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # ----------------------------------------------------------------------------
3 | # Licensed to the Apache Software Foundation (ASF) under one
4 | # or more contributor license agreements. See the NOTICE file
5 | # distributed with this work for additional information
6 | # regarding copyright ownership. The ASF licenses this file
7 | # to you under the Apache License, Version 2.0 (the
8 | # "License"); you may not use this file except in compliance
9 | # with the License. You may obtain a copy of the License at
10 | #
11 | # http://www.apache.org/licenses/LICENSE-2.0
12 | #
13 | # Unless required by applicable law or agreed to in writing,
14 | # software distributed under the License is distributed on an
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 | # KIND, either express or implied. See the License for the
17 | # specific language governing permissions and limitations
18 | # under the License.
19 | # ----------------------------------------------------------------------------
20 |
21 | # ----------------------------------------------------------------------------
22 | # Maven2 Start Up Batch script
23 | #
24 | # Required ENV vars:
25 | # ------------------
26 | # JAVA_HOME - location of a JDK home dir
27 | #
28 | # Optional ENV vars
29 | # -----------------
30 | # M2_HOME - location of maven2's installed home dir
31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven
32 | # e.g. to debug Maven itself, use
33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files
35 | # ----------------------------------------------------------------------------
36 |
37 | if [ -z "$MAVEN_SKIP_RC" ] ; then
38 |
39 | if [ -f /etc/mavenrc ] ; then
40 | . /etc/mavenrc
41 | fi
42 |
43 | if [ -f "$HOME/.mavenrc" ] ; then
44 | . "$HOME/.mavenrc"
45 | fi
46 |
47 | fi
48 |
49 | # OS specific support. $var _must_ be set to either true or false.
50 | cygwin=false;
51 | darwin=false;
52 | mingw=false
53 | case "`uname`" in
54 | CYGWIN*) cygwin=true ;;
55 | MINGW*) mingw=true;;
56 | Darwin*) darwin=true
57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
59 | if [ -z "$JAVA_HOME" ]; then
60 | if [ -x "/usr/libexec/java_home" ]; then
61 | export JAVA_HOME="`/usr/libexec/java_home`"
62 | else
63 | export JAVA_HOME="/Library/Java/Home"
64 | fi
65 | fi
66 | ;;
67 | esac
68 |
69 | if [ -z "$JAVA_HOME" ] ; then
70 | if [ -r /etc/gentoo-release ] ; then
71 | JAVA_HOME=`java-config --jre-home`
72 | fi
73 | fi
74 |
75 | if [ -z "$M2_HOME" ] ; then
76 | ## resolve links - $0 may be a link to maven's home
77 | PRG="$0"
78 |
79 | # need this for relative symlinks
80 | while [ -h "$PRG" ] ; do
81 | ls=`ls -ld "$PRG"`
82 | link=`expr "$ls" : '.*-> \(.*\)$'`
83 | if expr "$link" : '/.*' > /dev/null; then
84 | PRG="$link"
85 | else
86 | PRG="`dirname "$PRG"`/$link"
87 | fi
88 | done
89 |
90 | saveddir=`pwd`
91 |
92 | M2_HOME=`dirname "$PRG"`/..
93 |
94 | # make it fully qualified
95 | M2_HOME=`cd "$M2_HOME" && pwd`
96 |
97 | cd "$saveddir"
98 | # echo Using m2 at $M2_HOME
99 | fi
100 |
101 | # For Cygwin, ensure paths are in UNIX format before anything is touched
102 | if $cygwin ; then
103 | [ -n "$M2_HOME" ] &&
104 | M2_HOME=`cygpath --unix "$M2_HOME"`
105 | [ -n "$JAVA_HOME" ] &&
106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
107 | [ -n "$CLASSPATH" ] &&
108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
109 | fi
110 |
111 | # For Migwn, ensure paths are in UNIX format before anything is touched
112 | if $mingw ; then
113 | [ -n "$M2_HOME" ] &&
114 | M2_HOME="`(cd "$M2_HOME"; pwd)`"
115 | [ -n "$JAVA_HOME" ] &&
116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
117 | # TODO classpath?
118 | fi
119 |
120 | if [ -z "$JAVA_HOME" ]; then
121 | javaExecutable="`which javac`"
122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
123 | # readlink(1) is not available as standard on Solaris 10.
124 | readLink=`which readlink`
125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
126 | if $darwin ; then
127 | javaHome="`dirname \"$javaExecutable\"`"
128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
129 | else
130 | javaExecutable="`readlink -f \"$javaExecutable\"`"
131 | fi
132 | javaHome="`dirname \"$javaExecutable\"`"
133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'`
134 | JAVA_HOME="$javaHome"
135 | export JAVA_HOME
136 | fi
137 | fi
138 | fi
139 |
140 | if [ -z "$JAVACMD" ] ; then
141 | if [ -n "$JAVA_HOME" ] ; then
142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
143 | # IBM's JDK on AIX uses strange locations for the executables
144 | JAVACMD="$JAVA_HOME/jre/sh/java"
145 | else
146 | JAVACMD="$JAVA_HOME/bin/java"
147 | fi
148 | else
149 | JAVACMD="`which java`"
150 | fi
151 | fi
152 |
153 | if [ ! -x "$JAVACMD" ] ; then
154 | echo "Error: JAVA_HOME is not defined correctly." >&2
155 | echo " We cannot execute $JAVACMD" >&2
156 | exit 1
157 | fi
158 |
159 | if [ -z "$JAVA_HOME" ] ; then
160 | echo "Warning: JAVA_HOME environment variable is not set."
161 | fi
162 |
163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
164 |
165 | # traverses directory structure from process work directory to filesystem root
166 | # first directory with .mvn subdirectory is considered project base directory
167 | find_maven_basedir() {
168 |
169 | if [ -z "$1" ]
170 | then
171 | echo "Path not specified to find_maven_basedir"
172 | return 1
173 | fi
174 |
175 | basedir="$1"
176 | wdir="$1"
177 | while [ "$wdir" != '/' ] ; do
178 | if [ -d "$wdir"/.mvn ] ; then
179 | basedir=$wdir
180 | break
181 | fi
182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc)
183 | if [ -d "${wdir}" ]; then
184 | wdir=`cd "$wdir/.."; pwd`
185 | fi
186 | # end of workaround
187 | done
188 | echo "${basedir}"
189 | }
190 |
191 | # concatenates all lines of a file
192 | concat_lines() {
193 | if [ -f "$1" ]; then
194 | echo "$(tr -s '\n' ' ' < "$1")"
195 | fi
196 | }
197 |
198 | BASE_DIR=`find_maven_basedir "$(pwd)"`
199 | if [ -z "$BASE_DIR" ]; then
200 | exit 1;
201 | fi
202 |
203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
204 | echo $MAVEN_PROJECTBASEDIR
205 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
206 |
207 | # For Cygwin, switch paths to Windows format before running java
208 | if $cygwin; then
209 | [ -n "$M2_HOME" ] &&
210 | M2_HOME=`cygpath --path --windows "$M2_HOME"`
211 | [ -n "$JAVA_HOME" ] &&
212 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
213 | [ -n "$CLASSPATH" ] &&
214 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
215 | [ -n "$MAVEN_PROJECTBASEDIR" ] &&
216 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
217 | fi
218 |
219 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
220 |
221 | exec "$JAVACMD" \
222 | $MAVEN_OPTS \
223 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
224 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
225 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
226 |
--------------------------------------------------------------------------------