-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
570 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target/ |
64 changes: 64 additions & 0 deletions
64
springcloud-alibaba/springcloud-alibaba-nacos-feign/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
|
||
|
||
<groupId>com.pancm</groupId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<artifactId>springcloud-alibaba-nacos-fegin</artifactId> | ||
<packaging>jar</packaging> | ||
<name>pringcloud-alibaba-nacos-fegin</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
|
||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<java.version>1.8</java.version> | ||
<mysql-connector>5.1.44</mysql-connector> | ||
<logback>1.2.3</logback> | ||
<slf4j>1.7.25</slf4j> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
|
||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.2.1.RELEASE</version> | ||
<relativePath/> | ||
</parent> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<!-- Spring Boot Test 依赖 --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.alibaba.cloud</groupId> | ||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> | ||
<version>2.2.1.RELEASE</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.alibaba.cloud</groupId> | ||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> | ||
<version>2.2.1.RELEASE</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
|
||
|
||
|
||
</project> |
1 change: 1 addition & 0 deletions
1
...baba/springcloud-alibaba-nacos-feign/springcloud-alibaba-nacos-feign-consumer1/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target/ |
85 changes: 85 additions & 0 deletions
85
...alibaba/springcloud-alibaba-nacos-feign/springcloud-alibaba-nacos-feign-consumer1/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
|
||
|
||
<groupId>com.pancm</groupId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<artifactId>springcloud-alibaba-nacos-feign-consumer1</artifactId> | ||
<packaging>jar</packaging> | ||
<name>springcloud-alibaba-nacos-feign-consumer1</name> | ||
<url>http://maven.apache.org</url> | ||
|
||
|
||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
<java.version>1.8</java.version> | ||
<mysql-connector>5.1.44</mysql-connector> | ||
<logback>1.2.3</logback> | ||
<slf4j>1.7.25</slf4j> | ||
<knife4j-spring-boot-starter.version>3.0.3</knife4j-spring-boot-starter.version> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
|
||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.2.5.RELEASE</version> | ||
<relativePath/> | ||
</parent> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<!-- Spring Boot Test 依赖 --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.alibaba.cloud</groupId> | ||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId> | ||
<version>2.2.5.RELEASE</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.alibaba.cloud</groupId> | ||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId> | ||
<version>2.2.5.RELEASE</version> | ||
</dependency> | ||
|
||
<!-- feign --> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-starter-openfeign</artifactId> | ||
<version>2.2.5.RELEASE</version> | ||
</dependency> | ||
|
||
<!-- Swagger API文档 --> | ||
<dependency> | ||
<groupId>com.github.xiaoymin</groupId> | ||
<artifactId>knife4j-spring-boot-starter</artifactId> | ||
<version>${knife4j-spring-boot-starter.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
|
||
|
||
|
||
</project> |
30 changes: 30 additions & 0 deletions
30
...ba-nacos-feign/springcloud-alibaba-nacos-feign-consumer1/src/main/java/com/pancm/App.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.pancm; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; | ||
import org.springframework.cloud.openfeign.EnableFeignClients; | ||
|
||
|
||
/** | ||
* @Author pancm | ||
* @Description springboot集成nacos配置中心 | ||
* @Date 2024/1/26 | ||
* @Param | ||
* @return | ||
**/ | ||
@SpringBootApplication | ||
@EnableDiscoveryClient | ||
@EnableFeignClients | ||
public class App | ||
{ | ||
private static final Logger logger = LoggerFactory.getLogger(App.class); | ||
public static void main( String[] args ) | ||
{ | ||
// 启动嵌入式的 Tomcat 并初始化 Spring 环境及其各 Spring 组件 | ||
SpringApplication.run(App.class, args); | ||
logger.info("程序启动成功!"); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...pringcloud-alibaba-nacos-feign-consumer1/src/main/java/com/pancm/fegin/CosTestClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.pancm.fegin; | ||
|
||
|
||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RequestPart; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import java.util.Map; | ||
|
||
@FeignClient(value = "gdlh-common") | ||
@Component | ||
public interface CosTestClient { | ||
|
||
@PostMapping(value = "/file/upload",consumes = MediaType.MULTIPART_FORM_DATA_VALUE) | ||
Map upload(@RequestPart("file") MultipartFile file); | ||
} |
12 changes: 12 additions & 0 deletions
12
...n/springcloud-alibaba-nacos-feign-consumer1/src/main/java/com/pancm/fegin/TestClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.pancm.fegin; | ||
|
||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
|
||
@FeignClient(value = "jeecg-nacos-consumer2") | ||
@Component | ||
public interface TestClient { | ||
@GetMapping(value = "/config/getName") | ||
String getName(); | ||
} |
25 changes: 25 additions & 0 deletions
25
...ringcloud-alibaba-nacos-feign-consumer1/src/main/java/com/pancm/web/ConfigController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.pancm.web; | ||
|
||
import org.springframework.cloud.context.config.annotation.RefreshScope; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import static org.springframework.web.bind.annotation.RequestMethod.GET; | ||
|
||
/** | ||
* @Author pancm | ||
* @Description 官方示例文档 | ||
* @Date 2024/1/26 | ||
* @Param | ||
* @return | ||
**/ | ||
@RestController | ||
@RequestMapping("config") | ||
public class ConfigController { | ||
|
||
@RequestMapping(value = "/getAge", method = GET) | ||
public String getAge() { | ||
return "18"; | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
...gcloud-alibaba-nacos-feign-consumer1/src/main/java/com/pancm/web/FeignTestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.pancm.web; | ||
|
||
import com.pancm.fegin.CosTestClient; | ||
import com.pancm.fegin.TestClient; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.*; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* @Author pancm | ||
* @Description | ||
* @Date 2024/1/26 | ||
* @Param | ||
* @return | ||
**/ | ||
@RestController | ||
@RequestMapping("test") | ||
public class FeignTestController { | ||
|
||
@Autowired | ||
private TestClient testClient; | ||
|
||
@Autowired | ||
private CosTestClient cosTestClient; | ||
|
||
@GetMapping | ||
public String test() { | ||
return testClient.getName(); | ||
} | ||
|
||
|
||
|
||
@PostMapping("/upload") | ||
public Map upload(@RequestParam("file") MultipartFile multipartFile) { | ||
return cosTestClient.upload(multipartFile); | ||
} | ||
|
||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...-nacos-feign/springcloud-alibaba-nacos-feign-consumer1/src/main/resources/application.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
server: | ||
port: 9001 | ||
|
||
spring: | ||
application: | ||
# 服务名称 | ||
name: springcloud-alibaba-nacos-feign-consumer1 | ||
profiles: | ||
active: dev | ||
cloud: | ||
nacos: | ||
config: | ||
server-addr: 127.0.0.1 | ||
group: DEFAULT_GROUP | ||
namespace: gdlh | ||
discovery: | ||
server-addr: 127.0.0.1 | ||
group: DEFAULT_GROUP | ||
namespace: gdlh | ||
config: | ||
import: | ||
- optional:nacos:pancm.yaml | ||
- optional:nacos:pancm-@profile.name@.yaml |
32 changes: 32 additions & 0 deletions
32
...baba-nacos-feign/springcloud-alibaba-nacos-feign-consumer1/src/main/resources/logback.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration scan="true" scanPeriod="30 seconds" > | ||
<property name="LOG_HOME" value="logs"/> | ||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<layout class="ch.qos.logback.classic.PatternLayout"> | ||
<Pattern> | ||
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n | ||
</Pattern> | ||
</layout> | ||
</appender> | ||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy"> | ||
<!-- rollover daily --> | ||
<fileNamePattern>${LOG_HOME}/mylog-%d{yyyy-MM-dd}.%i.txt</fileNamePattern> | ||
<!-- each file should be at most 10MB, keep 31 days worth of history, but at most 10GB --> | ||
<maxFileSize>10MB</maxFileSize> | ||
<maxHistory>31</maxHistory> | ||
<totalSizeCap>10GB</totalSizeCap> | ||
</rollingPolicy> | ||
<layout class="ch.qos.logback.classic.PatternLayout"> | ||
<Pattern> | ||
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n | ||
</Pattern> | ||
</layout> | ||
</appender> | ||
|
||
<root level="INFO"> | ||
<appender-ref ref="STDOUT"/> | ||
<appender-ref ref="FILE" /> | ||
</root> | ||
|
||
</configuration> |
1 change: 1 addition & 0 deletions
1
...baba/springcloud-alibaba-nacos-feign/springcloud-alibaba-nacos-feign-consumer2/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target/ |
Oops, something went wrong.