mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
format code with maven plugins
This commit is contained in:
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.cloud.examples;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
|
@@ -1,6 +1,23 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.cloud.examples.controller;
|
||||
|
||||
import com.alibaba.cloud.examples.service.EchoService;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -12,12 +29,12 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
public class TestController {
|
||||
|
||||
@Autowired
|
||||
private EchoService echoService;
|
||||
@Autowired
|
||||
private EchoService echoService;
|
||||
|
||||
@GetMapping(value = "/echo-feign/{str}")
|
||||
public String feign(@PathVariable String str) {
|
||||
return echoService.echo(str);
|
||||
}
|
||||
@GetMapping("/echo-feign/{str}")
|
||||
public String feign(@PathVariable String str) {
|
||||
return echoService.echo(str);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.cloud.examples.fallback;
|
||||
|
||||
import com.alibaba.cloud.examples.service.EchoService;
|
||||
@@ -9,20 +25,21 @@ import com.alibaba.cloud.examples.service.EchoService;
|
||||
* sentinel 降级处理
|
||||
*/
|
||||
public class EchoServiceFallback implements EchoService {
|
||||
private Throwable throwable;
|
||||
|
||||
EchoServiceFallback(Throwable throwable) {
|
||||
this.throwable = throwable;
|
||||
}
|
||||
private Throwable throwable;
|
||||
|
||||
EchoServiceFallback(Throwable throwable) {
|
||||
this.throwable = throwable;
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用服务提供方的输出接口
|
||||
* @param str 用户输入
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String echo(String str) {
|
||||
return "consumer-fallback-default-str" + throwable.getMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用服务提供方的输出接口
|
||||
*
|
||||
* @param str 用户输入
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String echo(String str) {
|
||||
return "consumer-fallback-default-str" + throwable.getMessage();
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,23 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.cloud.examples.fallback;
|
||||
|
||||
import feign.hystrix.FallbackFactory;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
@@ -9,8 +26,10 @@ import org.springframework.stereotype.Component;
|
||||
*/
|
||||
@Component
|
||||
public class EchoServiceFallbackFactory implements FallbackFactory<EchoServiceFallback> {
|
||||
@Override
|
||||
public EchoServiceFallback create(Throwable throwable) {
|
||||
return new EchoServiceFallback(throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EchoServiceFallback create(Throwable throwable) {
|
||||
return new EchoServiceFallback(throwable);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,23 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.cloud.examples.service;
|
||||
|
||||
import com.alibaba.cloud.examples.fallback.EchoServiceFallbackFactory;
|
||||
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@@ -11,15 +28,16 @@ import org.springframework.web.bind.annotation.PathVariable;
|
||||
* <p>
|
||||
* example feign client
|
||||
*/
|
||||
@FeignClient(name = "service-provider", fallbackFactory = EchoServiceFallbackFactory.class)
|
||||
@FeignClient(name = "service-provider",
|
||||
fallbackFactory = EchoServiceFallbackFactory.class)
|
||||
public interface EchoService {
|
||||
|
||||
/**
|
||||
* 调用服务提供方的输出接口
|
||||
*
|
||||
* @param str 用户输入
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/echo/{str}")
|
||||
String echo(@PathVariable("str") String str);
|
||||
/**
|
||||
* 调用服务提供方的输出接口
|
||||
* @param str 用户输入
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/echo/{str}")
|
||||
String echo(@PathVariable("str") String str);
|
||||
|
||||
}
|
||||
|
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.cloud.examples;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
@@ -11,7 +27,8 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
@SpringBootApplication
|
||||
public class ProviderApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ProviderApplication.class, args);
|
||||
}
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ProviderApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.alibaba.cloud.examples.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -11,9 +27,9 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RestController
|
||||
public class EchoController {
|
||||
|
||||
@GetMapping("/echo/{str}")
|
||||
public String echo(@PathVariable String str) {
|
||||
return "provider-" + str;
|
||||
}
|
||||
@GetMapping("/echo/{str}")
|
||||
public String echo(@PathVariable String str) {
|
||||
return "provider-" + str;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user