初始化

This commit is contained in:
huangsimin 2022-07-01 14:36:57 +08:00
commit ff8de464f5
10 changed files with 480 additions and 0 deletions

129
.gitignore vendored Normal file
View File

@ -0,0 +1,129 @@
# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,linux,git,gradle,java,maven
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,linux,git,gradle,java,maven
### Git ###
# Created by git for backups. To disable backups in Git:
# $ git config --global mergetool.keepBackup false
*.orig
# Created by git when using merge tools for conflicts
*.BACKUP.*
*.BASE.*
*.LOCAL.*
*.REMOTE.*
*_BACKUP_*.txt
*_BASE_*.txt
*_LOCAL_*.txt
*_REMOTE_*.txt
### Java ###
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar
# Eclipse m2e generated files
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath
### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
# Local History for Visual Studio Code
.history/
# Built Visual Studio Code Extensions
*.vsix
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide
# Support for Project snippet scope
.vscode/*.code-snippets
# Ignore code-workspaces
*.code-workspace
### Gradle ###
.gradle
**/build/
!src/**/build/
# Ignore Gradle GUI config
gradle-app.setting
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
# Avoid ignore Gradle wrappper properties
!gradle-wrapper.properties
# Cache of project
.gradletasknamecache
# Eclipse Gradle plugin generated files
# Eclipse Core
# JDT-specific (Eclipse Java Development Tools)
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,linux,git,gradle,java,maven
# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "automatic"
}

14
README.md Normal file
View File

@ -0,0 +1,14 @@
# 源典骨架
## 使用方式
* git clone <this-git> clone git仓库
* 安装骨架
```bash
git clone <this-git> # clone git仓库
mvn archetype:create-from-project
cd target/generated-sources/archetype
mvn install
```
*

150
pom.xml Normal file
View File

@ -0,0 +1,150 @@
<?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.yuandian.common</groupId>
<artifactId>database</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>yd-common-archetype</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<java.version>8</java.version>
<nacos.version>2.1.0</nacos.version>
<snakeyaml.version>1.30</snakeyaml.version>
<logback.version>1.2.11</logback.version>
<slf4j.version>1.7.36</slf4j.version>
</properties>
<!-- 测试依赖 -->
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<!-- 添加项目需求的依赖 start -->
<!-- https://mvnrepository.com/artifact/org.mongodb/mongodb-driver -->
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver</artifactId>
<version>3.12.11</version>
</dependency>
<dependency>
<groupId>com.yuandian.common</groupId>
<artifactId>config</artifactId>
<version>1.0.4</version>
</dependency>
<!-- 添加项目需求的依赖 end -->
<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->
<!-- <dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency> -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>${snakeyaml.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
<version>${nacos.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>
</dependencies>
<scm>
<connection>scm:git:http://git.yuandian.com/project/yd-common-config.git</connection>
<url>http://git.yuandian.com/project/yd-common-config.git</url>
<developerConnection>scm:git:http://git.yuandian.com/project/yd-common-config.git</developerConnection>
<tag>HEAD</tag>
</scm>
<distributionManagement>
<snapshotRepository>
<id>yuandian-nexus</id>
<name>yuandian-snapshots</name>
<url>http://mvn.yuandian.com/repository/maven-snapshots</url>
</snapshotRepository>
<repository>
<id>yuandian-nexus</id>
<name>yuandian-releases</name>
<url>http://mvn.yuandian.com/repository/maven-releases</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<tagNameFormat>v@{project.version}</tagNameFormat>
<autoVersionSubmodules>true</autoVersionSubmodules>
<releaseProfiles>releases</releaseProfiles>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nxrm3-maven-plugin</artifactId>
<version>1.0.4</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
<configuration>
<nexusUrl>http://mvn.yuandian.com</nexusUrl>
<!-- The server "id" element from settings to use authentication from settings.xml-->
<serverId>yuandian-nexus</serverId>
<!-- Which repository to deploy to -->
<repository>maven-snapshots</repository>
<!-- Skip the staging deploy mojo -->
<skipNexusStagingDeployMojo>true</skipNexusStagingDeployMojo>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,16 @@
package com.yuandian.common;
import lombok.extern.slf4j.Slf4j;
/**
* Hello world!
*
*/
@Slf4j
public class App
{
public static void main( String[] args )
{
log.info("Hello Yuandian!");
}
}

View File

@ -0,0 +1,87 @@
/**
* description
*
* @author eson
*2022年6月29日-10:16:15
*/
package com.yuandian.common;
import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import org.bson.BsonDocument;
import org.bson.codecs.configuration.CodecRegistry;
import org.bson.conversions.Bson;
import com.mongodb.BasicDBObject;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientURI;
import com.mongodb.client.model.IndexOptions;
import com.mongodb.client.model.Indexes;
import lombok.var;
import lombok.extern.slf4j.Slf4j;
/**
* description
*
* @author eson
*2022年6月29日-10:16:15
*/
@Slf4j
public class Database {
public class Origin<T> {
T client;
}
public static void main(String[] args) throws Exception {
Config.UseConfig("yuandian.database", (cnf) -> {
Map<String,Object> oriConfig = cnf.get("database", "mongodb", "ori");
String uri = (String)oriConfig.get("uri"); // 获取 uri配置
MongoClient client = new MongoClient(new MongoClientURI(uri));
var dbInfoList = (ArrayList)oriConfig.get("db_info_list"); // 获取 db_info_list 列表
return null;
});
// var cOriName = "bus_db";
// var db = client.getDatabase("yd-base");
// var busDB = db.getCollection(cOriName);
// var cur = busDB.listIndexes().iterator();
// if(!cur.hasNext()) {
// var bs = new BasicDBObject();
// bs.js
// bs.append("create_at", "1");
// bs.append("key", mapAsJavaMap(Map(("_id", "hashed"))))
// busDB.createIndex(keys)
// db.ex("db.db_bus.createIndex({ create_at: 1 },{expireAfterSeconds: 3600})");
// var opt = new IndexOptions().expireAfter((long) 3600, TimeUnit.SECONDS);
// cOri.createIndex(Indexes.ascending("create_at"), opt);
// }
// db.createCollection(cOriName);
}
}

View File

@ -0,0 +1,7 @@
# 启动端口 具体由项目而定
# server.port=3440
# 测试环境的 nacos 配置地址
yuandian.dataflow.config.nacos.server.addr=config.yuandian.local:8848
# 测试环境的 nacos 配置地址
yuandian.dataflow.config.nacos.server.addr-test=config.yuandian.local:8848

View File

@ -0,0 +1,44 @@
// MongoDB Playground
// Use Ctrl+Space inside a snippet or a string literal to trigger completions.
const database = 'yd-base';
const collection = 'db_bus';
// The current database to use.
use(database);
// Create a new collection.
// db.createCollection(collection);
// c = db.getCollection(collation);
db.db_bus.createIndex({ create_at: 1 },{expireAfterSeconds: 3600})
// The prototype form to create a regular collection:
/* db.createCollection( <name>,
{
capped: <boolean>,
autoIndexId: <boolean>,
size: <number>,
max: <number>,
storageEngine: <document>,
validator: <document>,
validationLevel: <string>,
validationAction: <string>,
indexOptionDefaults: <document>,
viewOn: <string>,
pipeline: <pipeline>,
collation: <document>,
writeConcern: <document>
}
) */
// The prototype form to create a time-series collection:
/* db.createCollection( <name>,
{
timeseries: {
timeField: <string>,
metaField: <string>,
granularity: <string>
},
expireAfterSeconds: <number>
}
) */

View File

@ -0,0 +1,13 @@
<configuration>
<appender name="CONSOLE"
class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>
%d{yyyyMMdd HH:mm:ss.SSS} %level %thread\(%file:%line\): %msg%n
</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="CONSOLE" />
</root>
</configuration>

View File

@ -0,0 +1,17 @@
package com.yuandian.common;
import static org.junit.jupiter.api.Assertions.assertAll;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
@TestMethodOrder(OrderAnnotation.class)
public class AppTest {
@Test
@Order(1)
void testApp() {
//TODO: test 参考 http://doc.yuandian.com/pages/viewpage.action?pageId=4391012
}
}