Remove sensitive information and initialize.
This commit is contained in:
33
.gitignore
vendored
Normal file
33
.gitignore
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
134
pom.xml
Normal file
134
pom.xml
Normal file
@@ -0,0 +1,134 @@
|
||||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.2.3</version>
|
||||
<relativePath /> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.flagnote</groupId>
|
||||
<artifactId>flagnote-config</artifactId>
|
||||
<version>0.0.1</version>
|
||||
<name>flagnote-config</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<maven.compiler.compilerVersion>17</maven.compiler.compilerVersion>
|
||||
<spring-cloud.version>2023.0.0</spring-cloud.version>
|
||||
<docker.repostory>registry.openif.com:5000</docker.repostory>
|
||||
<docker.registry.name>flagnote</docker.registry.name>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-config-server</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>${spring-cloud.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
<showWarnings>true</showWarnings>
|
||||
<fork>true</fork>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/configs/*.yml</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<configuration>
|
||||
<serverId>docker-openif</serverId>
|
||||
<registryUrl>http://${docker.repository}</registryUrl>
|
||||
<pushImage>true</pushImage>
|
||||
<dockerHost>http://144.34.221.20:42375</dockerHost>
|
||||
<imageName>
|
||||
${docker.repostory}/${docker.registry.name}/${project.artifactId}:${project.version}
|
||||
</imageName>
|
||||
<dockerDirectory>src/main/docker</dockerDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>/</targetPath>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<include>${project.build.finalName}.jar</include>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
6
src/main/docker/dockerfile
Normal file
6
src/main/docker/dockerfile
Normal file
@@ -0,0 +1,6 @@
|
||||
FROM registry.openif.com:5000/flagnote/flagnote-docker-image:0.0.1
|
||||
VOLUME /tmp
|
||||
ADD flagnote-config-0.0.1.jar app.jar
|
||||
RUN sh -c 'touch /app.jar'
|
||||
ENV JAVA_OPTS=""
|
||||
ENTRYPOINT [ "sh", "-c", "exec java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ]
|
||||
16
src/main/java/com/flagnote/config/ConfigApplication.java
Normal file
16
src/main/java/com/flagnote/config/ConfigApplication.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package com.flagnote.config;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.config.server.EnableConfigServer;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
@EnableConfigServer
|
||||
public class ConfigApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ConfigApplication.class, args);
|
||||
}
|
||||
}
|
||||
36
src/main/resources/bootstrap.yml
Normal file
36
src/main/resources/bootstrap.yml
Normal file
@@ -0,0 +1,36 @@
|
||||
server:
|
||||
port: 20000
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: flagnote-config
|
||||
|
||||
profiles:
|
||||
active: native
|
||||
cloud:
|
||||
config:
|
||||
server:
|
||||
native:
|
||||
searchLocations: classpath:/configs,file:/usr/local/flagnote/etc
|
||||
|
||||
management:
|
||||
# server:
|
||||
# address: 127.0.0.1
|
||||
# port: 19000
|
||||
endpoint:
|
||||
shutdown:
|
||||
enabled: true
|
||||
health:
|
||||
enabled: true
|
||||
show-details: always
|
||||
endpoints:
|
||||
web:
|
||||
base-path: /xxxxxx/actuator
|
||||
exposure:
|
||||
include: shutdown,health
|
||||
|
||||
|
||||
logging:
|
||||
config: classpath:logback-spring.xml
|
||||
logback:
|
||||
logPath: /tmp/logs/
|
||||
189
src/main/resources/configs/flagnote-gateway-dev.yml
Normal file
189
src/main/resources/configs/flagnote-gateway-dev.yml
Normal file
@@ -0,0 +1,189 @@
|
||||
server:
|
||||
# address: 127.0.0.1
|
||||
port: 21000
|
||||
spring:
|
||||
data:
|
||||
redis:
|
||||
database: 10
|
||||
host: localhost
|
||||
port: 6379
|
||||
timeout: 10000
|
||||
poolMaxTotal: 10
|
||||
poolMaxIdle: 10
|
||||
poolMaxWait: 3
|
||||
password: redispassword
|
||||
codec:
|
||||
max-in-memory-size: 10MB
|
||||
servlet:
|
||||
multipart:
|
||||
# 最大支持文件大小
|
||||
max-file-size: 10MB
|
||||
# 最大支持请求大小
|
||||
max-request-size: 10MB
|
||||
|
||||
cloud:
|
||||
gateway:
|
||||
routes:
|
||||
- id: redirect
|
||||
uri: lb://flagnote-service
|
||||
order: -1
|
||||
predicates:
|
||||
- Path=/html/redirect
|
||||
- Method=GET
|
||||
filters:
|
||||
- name: RequestRateLimiter
|
||||
args:
|
||||
# 如果返回的key是空的话,false则不进行限流
|
||||
# deny-empty-key: true
|
||||
# status-code: TOO_MANY_REQUESTS
|
||||
# 每秒产生多少个令牌
|
||||
redis-rate-limiter.replenishRate: 1
|
||||
# 1秒内最大的令牌,即在1s内可以允许的突发流程,设置为0,表示阻止所有的请求
|
||||
redis-rate-limiter.burstCapacity: 10
|
||||
# 每次请求申请几个令牌
|
||||
redis-rate-limiter.requestedTokens: 1
|
||||
# IP 地址限流
|
||||
key-resolver: "#{@remoteAddrKeyResolver}"
|
||||
|
||||
|
||||
- name: RequestRateLimiter
|
||||
args:
|
||||
# 如果返回的key是空的话,false则不进行限流
|
||||
# deny-empty-key: true
|
||||
# status-code: TOO_MANY_REQUESTS
|
||||
# 每秒产生多少个令牌
|
||||
redis-rate-limiter.replenishRate: 1
|
||||
# 1秒内最大的令牌,即在1s内可以允许的突发流程,设置为0,表示阻止所有的请求
|
||||
redis-rate-limiter.burstCapacity: 10
|
||||
# 每次请求申请几个令牌
|
||||
redis-rate-limiter.requestedTokens: 2
|
||||
# IP 地址限流
|
||||
key-resolver: "#{@remoteSessionKeyResolver}"
|
||||
|
||||
- id: keyMeta
|
||||
uri: lb://flagnote-service
|
||||
order: -1
|
||||
predicates:
|
||||
- Path=/note/keyMeta
|
||||
- Method=GET
|
||||
filters:
|
||||
- name: RequestRateLimiter
|
||||
args:
|
||||
# 如果返回的key是空的话,false则不进行限流
|
||||
# deny-empty-key: true
|
||||
# status-code: TOO_MANY_REQUESTS
|
||||
# 每秒产生多少个令牌
|
||||
redis-rate-limiter.replenishRate: 1
|
||||
# 1秒内最大的令牌,即在1s内可以允许的突发流程,设置为0,表示阻止所有的请求
|
||||
redis-rate-limiter.burstCapacity: 10
|
||||
# 每次请求申请几个令牌
|
||||
redis-rate-limiter.requestedTokens: 1
|
||||
# IP 地址限流
|
||||
key-resolver: "#{@remoteAddrKeyResolver}"
|
||||
|
||||
|
||||
- name: RequestRateLimiter
|
||||
args:
|
||||
# 如果返回的key是空的话,false则不进行限流
|
||||
# deny-empty-key: true
|
||||
# status-code: TOO_MANY_REQUESTS
|
||||
# 每秒产生多少个令牌
|
||||
redis-rate-limiter.replenishRate: 1
|
||||
# 1秒内最大的令牌,即在1s内可以允许的突发流程,设置为0,表示阻止所有的请求
|
||||
redis-rate-limiter.burstCapacity: 10
|
||||
# 每次请求申请几个令牌
|
||||
redis-rate-limiter.requestedTokens: 2
|
||||
# IP 地址限流
|
||||
key-resolver: "#{@remoteSessionKeyResolver}"
|
||||
|
||||
|
||||
|
||||
- id: noteMeta
|
||||
uri: lb://flagnote-service
|
||||
order: -1
|
||||
predicates:
|
||||
- Path=/note/{key:[abcdefhikmnopqstuvwxyz23456789]{16}}/noteMeta
|
||||
- Method=GET
|
||||
filters:
|
||||
- ValidateNoteKey
|
||||
- id: getNote
|
||||
uri: lb://flagnote-service
|
||||
order: -1
|
||||
predicates:
|
||||
- Path=/note/{key:[abcdefhikmnopqstuvwxyz23456789]{16}}
|
||||
- Method=GET
|
||||
filters:
|
||||
- ValidateNoteKey
|
||||
- id: saveNote
|
||||
uri: lb://flagnote-service
|
||||
order: -1
|
||||
predicates:
|
||||
- Path=/note/{key:[abcdefhikmnopqstuvwxyz23456789]{16}}
|
||||
- Method=POST
|
||||
filters:
|
||||
- ValidateNoteKey
|
||||
- id: deleteNote
|
||||
uri: lb://flagnote-service
|
||||
order: -1
|
||||
predicates:
|
||||
- Path=/note/{key:[abcdefhikmnopqstuvwxyz23456789]{16}}/delete
|
||||
- Method=POST
|
||||
filters:
|
||||
- ValidateNoteKey
|
||||
- id: secretKey
|
||||
uri: lb://flagnote-service
|
||||
order: -1
|
||||
predicates:
|
||||
- Path=/note/{key:[abcdefhikmnopqstuvwxyz23456789]{16}}/secretKey
|
||||
- Method=POST
|
||||
filters:
|
||||
- ValidateNoteKey
|
||||
- id: getNoteTxt
|
||||
uri: lb://flagnote-service
|
||||
order: -1
|
||||
predicates:
|
||||
- Path=/note/{key:[abcdefhikmnopqstuvwxyz23456789]{16}}.txt
|
||||
- Method=GET
|
||||
filters:
|
||||
- ValidateNoteKey
|
||||
|
||||
zookeeper:
|
||||
connect-string: localhost:2181
|
||||
discovery:
|
||||
enabled: true
|
||||
|
||||
loadbalancer:
|
||||
configurations: health-check
|
||||
health-check:
|
||||
path:
|
||||
noteCommonService: /xxxxxx/actuator/health
|
||||
keyMetaService: /xxxxxx/actuator/health
|
||||
initial-delay: 0
|
||||
interval: 5s
|
||||
inetutils:
|
||||
# 指定此客户端的ip
|
||||
default-ip-address: localhost
|
||||
|
||||
|
||||
|
||||
management:
|
||||
# server:
|
||||
# address: 127.0.0.1
|
||||
# port: 19000
|
||||
endpoint:
|
||||
shutdown:
|
||||
enabled: true
|
||||
health:
|
||||
enabled: true
|
||||
show-details: always
|
||||
endpoints:
|
||||
web:
|
||||
base-path: /xxxxxx/actuator
|
||||
exposure:
|
||||
include: shutdown,health
|
||||
|
||||
logging:
|
||||
level:
|
||||
org.springframework.cloud.gateway: trace
|
||||
org.springframework.cloud.loadbalancer: trace
|
||||
org.springframework.web.reactive: trace
|
||||
49
src/main/resources/configs/flagnote-service-dev.yml
Normal file
49
src/main/resources/configs/flagnote-service-dev.yml
Normal file
@@ -0,0 +1,49 @@
|
||||
server:
|
||||
port: 22000
|
||||
|
||||
spring:
|
||||
codec:
|
||||
max-in-memory-size: 10MB
|
||||
data:
|
||||
mongodb:
|
||||
authentication-database: admin
|
||||
database: flagnote
|
||||
host: localhost
|
||||
port: 27017
|
||||
username: mongoadmin
|
||||
password: mongopassword
|
||||
autoConnectRetry: true
|
||||
socketKeepAlive: true
|
||||
socketTimeout: 10000
|
||||
cloud:
|
||||
zookeeper:
|
||||
connect-string: localhost:2181
|
||||
discovery:
|
||||
enabled: true
|
||||
freemarker:
|
||||
suffix: .ftl
|
||||
content-type: text/html;charset=utf-8
|
||||
enabled: true
|
||||
cache: true
|
||||
template-loader-path: classpath:/templates/
|
||||
charset: UTF-8
|
||||
management:
|
||||
endpoint:
|
||||
shutdown:
|
||||
enabled: true
|
||||
health:
|
||||
enabled: true
|
||||
endpoints:
|
||||
web:
|
||||
base-path: /xxxxxx/actuator
|
||||
exposure:
|
||||
include: shutdown,health
|
||||
|
||||
logging:
|
||||
level:
|
||||
org:
|
||||
springframework:
|
||||
data:
|
||||
mongodb:
|
||||
core:
|
||||
MongoTemplate: DEBUG
|
||||
35
src/main/resources/logback-spring.xml
Normal file
35
src/main/resources/logback-spring.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<springProperty scope="context" name="logPath" source="logback.logPath"/>
|
||||
<property name="pattern" value="[%date{yyyy-MM-dd HH:mm:ss.SSS}] %X{logthreadId} %-5level %logger{80} %method %line - %msg%n"/>
|
||||
<property name="charsetEncoding" value="UTF-8"/>
|
||||
<property name="LOG_HOME" value="${logPath}"/>
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${pattern}</pattern>
|
||||
<charset>${charsetEncoding}</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
<appender name="infoLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<append>true</append>
|
||||
<encoder>
|
||||
<pattern>${pattern}</pattern>
|
||||
<charset>${charsetEncoding}</charset>
|
||||
</encoder>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>
|
||||
${LOG_HOME}${file.separator}%d{yyMMdd}_info_%i.log
|
||||
</fileNamePattern>
|
||||
<maxHistory>30</maxHistory>
|
||||
<maxFileSize>20MB</maxFileSize>
|
||||
</rollingPolicy>
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>INFO</level>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="console"/>
|
||||
<appender-ref ref="infoLog"/>
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.flagnote.flagnoteconfig;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class FlagnoteConfigApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user