Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwujing committed Jan 29, 2024
1 parent 387d15d commit 53b58a1
Show file tree
Hide file tree
Showing 33 changed files with 994 additions and 0 deletions.
38 changes: 38 additions & 0 deletions springcloud-alibaba/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
11 changes: 11 additions & 0 deletions springcloud-alibaba/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## springcloud-alibaba

### 介绍

> springcloud-alibaba 是一系列组件的集合,它为Spring Cloud提供了许多优秀的补充。
> 它包括Spring Cloud Gateway、Nacos、Sentinel、Seata、Sentinel等。
> 这些组件可以提高Spring Cloud应用程序的性能、可靠性、可扩展性和可管理性。
官方文档地址:
https://sca.aliyun.com/zh-cn/docs/2022.0.0.0/overview/what-is-sca

84 changes: 84 additions & 0 deletions springcloud-alibaba/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.pancm</groupId>
<artifactId>springcloud-alibaba</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version>
<relativePath/>
</parent>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<slf4j.version>1.7.25</slf4j.version>
<logback.version>1.2.3</logback.version>
</properties>

<name>springcloud-alibaba</name>
<url>http://maven.apache.org</url>
<description>springcloud-alibaba demo</description>



<modules>
<module>springcloud-alibaba-nacos</module>
<module>springcloud-alibaba-sentinel</module>
<module>springcloud-alibaba-seata</module>
<module>springcloud-alibaba-sideca</module>
</modules>



<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
</dependency>

<!-- log -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>

</dependencies>


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


</project>
1 change: 1 addition & 0 deletions springcloud-alibaba/springcloud-alibaba-nacos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
64 changes: 64 additions & 0 deletions springcloud-alibaba/springcloud-alibaba-nacos/pom.xml
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</artifactId>
<packaging>jar</packaging>
<name>springboot-nacos</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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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;


/**
* @Author pancm
* @Description springboot集成nacos配置中心
* @Date 2024/1/26
* @Param
* @return
**/
@SpringBootApplication
@EnableDiscoveryClient
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("程序启动成功!");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.pancm.web;

import org.springframework.beans.factory.annotation.Value;
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")
@RefreshScope
public class ConfigController {



@Value("${pcm.name:pcm-1001}")
private String name;

@Value("${pcm.age:18}")
private String age;


@RequestMapping(value = "/getAge", method = GET)
public String getAge() {
return age;
}

@RequestMapping(value = "/getName", method = GET)
public String getName() {
return name;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.pancm.web;

import com.alibaba.nacos.api.annotation.NacosInjected;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.NamingService;
import com.alibaba.nacos.api.naming.pojo.Instance;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static org.springframework.web.bind.annotation.RequestMethod.GET;

@RestController
@RequestMapping("discovery")
public class DiscoveryController {

@NacosInjected
private NamingService namingService;

@RequestMapping(value = "/get", method = GET)
public List<Instance> get(@RequestParam String serviceName) throws NacosException {
return namingService.getAllInstances(serviceName);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
spring.banner.charset=UTF-8
server.tomcat.uri-encoding=UTF-8
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true
spring.messages.encoding=UTF-8
server.port=8299
spring.application.name=springboot-nacos
spring.profiles.active=dev


# nacos??
nacos.discovery.autoRegister=true
spring.cloud.nacos.discovery.server-addr= http://127.0.0.1:8848
spring.cloud.nacos.config.server-addr= http://127.0.0.1:8848
spring.cloud.nacos.config.namespace= pcm-namespace--id
spring.cloud.nacos.config.group= dev
spring.cloud.nacos.config.fileExtension= properties


# ??????
##???????????dataId
spring.cloud.nacos.config.extension-configs[0].data-id=pcm-dev.properties
##?????????????
spring.cloud.nacos.config.extension-configs[0].group=dev



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>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pcm.age = 24
1 change: 1 addition & 0 deletions springcloud-alibaba/springcloud-alibaba-seata/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
Loading

0 comments on commit 53b58a1

Please sign in to comment.