mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-14 04:16:53 +00:00
feat[boot]: 支持spring boot的自动化配置
This commit is contained in:
1 parent
47be79785e
commit
44e4782641
37 files changed
+657
-219
No files matched your search
+252
@@ -0,0 +1,252 @@
|
||||
<?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.zfoo</groupId>
|
||||
<artifactId>boot</artifactId>
|
||||
<version>3.0</version>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
||||
<properties>
|
||||
<!-- 本项目的其它module版本号 -->
|
||||
<zfoo.boot.version>3.0</zfoo.boot.version>
|
||||
<zfoo.event.version>3.0</zfoo.event.version>
|
||||
<zfoo.hotswap.version>3.0</zfoo.hotswap.version>
|
||||
<zfoo.monitor.version>3.0</zfoo.monitor.version>
|
||||
<zfoo.net.version>3.0</zfoo.net.version>
|
||||
<zfoo.scheduler.version>3.0</zfoo.scheduler.version>
|
||||
<zfoo.storage.version>3.0</zfoo.storage.version>
|
||||
<zfoo.orm.version>3.0</zfoo.orm.version>
|
||||
<zfoo.protocol.version>3.0</zfoo.protocol.version>
|
||||
<zfoo.util.version>3.0</zfoo.util.version>
|
||||
|
||||
|
||||
<!-- 核心spring框架 -->
|
||||
<spring.version>5.3.4</spring.version>
|
||||
<spring.boot.version>2.4.3</spring.boot.version>
|
||||
|
||||
|
||||
<!-- 工具包 -->
|
||||
<commons-codec.version>1.15</commons-codec.version>
|
||||
<commons-io.version>2.8.0</commons-io.version>
|
||||
<commons-collections.version>4.4</commons-collections.version>
|
||||
<commons-lang.version>3.12.0</commons-lang.version>
|
||||
<commons-fileupload.version>1.4</commons-fileupload.version>
|
||||
<commons-logging.version>1.2</commons-logging.version>
|
||||
<commons-log4j.version>2.14.0</commons-log4j.version>
|
||||
<httpcomponents.version>4.5.13</httpcomponents.version>
|
||||
<httpcore.version>4.4.14</httpcore.version>
|
||||
<google.guava.version>30.1-jre</google.guava.version>
|
||||
<google.protobuf.version>3.9.1</google.protobuf.version>
|
||||
<google.gson.version>2.8.6</google.gson.version>
|
||||
<kryo.version>5.0.3</kryo.version>
|
||||
<caffeine.version>2.8.8</caffeine.version>
|
||||
<jctools.version>3.2.0</jctools.version>
|
||||
<hutool.version>5.5.9</hutool.version>
|
||||
<oshi.version>5.7.0</oshi.version>
|
||||
<snakeyaml.version>1.28</snakeyaml.version>
|
||||
|
||||
|
||||
<!-- json和xml解析包 -->
|
||||
<jackson.version>2.12.1</jackson.version>
|
||||
<fastjson.version>1.2.51</fastjson.version>
|
||||
<!-- office文档解析包 -->
|
||||
<poi.version>4.1.2</poi.version>
|
||||
<!-- 字节码增强 -->
|
||||
<javassist.version>3.27.0-GA</javassist.version>
|
||||
<bytebuddy.version>1.10.22</bytebuddy.version>
|
||||
|
||||
<!-- 网络通讯框架 -->
|
||||
<netty.version>4.1.63.Final</netty.version>
|
||||
|
||||
<!-- 分布式zookeeper核心依赖包 -->
|
||||
<zookeeper.version>3.6.1</zookeeper.version>
|
||||
<curator.version>5.1.0</curator.version>
|
||||
|
||||
<!-- 数据库和缓存 -->
|
||||
<mongodb-driver-sync.version>4.2.1</mongodb-driver-sync.version>
|
||||
<jedis.version>3.3.0</jedis.version>
|
||||
|
||||
<!-- 消息队列中间件 -->
|
||||
<rocketmq.version>4.5.2</rocketmq.version>
|
||||
|
||||
<!-- elastic search 中间件 -->
|
||||
<elastic.search.version>7.9.3</elastic.search.version>
|
||||
<elastic.search.spring.version>4.1.5</elastic.search.spring.version>
|
||||
<lucene.version>8.6.2</lucene.version>
|
||||
|
||||
|
||||
<slf4j.version>1.7.30</slf4j.version>
|
||||
<logback.version>1.2.3</logback.version>
|
||||
|
||||
<junit.version>4.12</junit.version>
|
||||
|
||||
<!-- java版本和文件编码 -->
|
||||
<java.version>11</java.version>
|
||||
<file.encoding>UTF-8</file.encoding>
|
||||
<jakarta.version>1.3.5</jakarta.version>
|
||||
|
||||
<!-- maven核心插件 -->
|
||||
<maven-clean-plugin.version>3.1.0</maven-clean-plugin.version>
|
||||
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
|
||||
<maven-resources-plugin.version>3.2.0</maven-resources-plugin.version>
|
||||
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
|
||||
<maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
|
||||
<maven-shade-plugin.version>3.2.4</maven-shade-plugin.version>
|
||||
<versions-maven-plugin.version>2.8.1</versions-maven-plugin.version>
|
||||
|
||||
|
||||
<project.build.sourceEncoding>${file.encoding}</project.build.sourceEncoding>
|
||||
<maven.compiler.encoding>${file.encoding}</maven.compiler.encoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.zfoo</groupId>
|
||||
<artifactId>net</artifactId>
|
||||
<version>${zfoo.net.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.zfoo</groupId>
|
||||
<artifactId>orm</artifactId>
|
||||
<version>${zfoo.orm.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.zfoo</groupId>
|
||||
<artifactId>event</artifactId>
|
||||
<version>${zfoo.event.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.zfoo</groupId>
|
||||
<artifactId>scheduler</artifactId>
|
||||
<version>${zfoo.scheduler.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.zfoo</groupId>
|
||||
<artifactId>storage</artifactId>
|
||||
<version>${zfoo.storage.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- slf4j-api -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
<!-- logback核心包 -->
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-core</artifactId>
|
||||
<version>${logback.version}</version>
|
||||
</dependency>
|
||||
<!-- logback的sl4j的实现 -->
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>${logback.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<groupId>org.slf4j</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- 依赖的测试库 -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<testSourceDirectory>src/test/java</testSourceDirectory>
|
||||
|
||||
<plugins>
|
||||
|
||||
<!-- 清理插件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>${maven-clean-plugin.version}</version>
|
||||
</plugin>
|
||||
|
||||
<!-- 编译插件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>${maven-compiler-plugin.version}</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<encoding>${file.encoding}</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- resource资源管理插件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>${maven-resources-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<encoding>${file.encoding}</encoding>
|
||||
<outputDirectory>${project.build.directory}/resource</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources/</directory>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
|
||||
<!-- 测试插件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>${maven-surefire-plugin.version}</version>
|
||||
<configuration>
|
||||
<forkMode>once</forkMode>
|
||||
<threadCount>10</threadCount>
|
||||
<argLine>-Dfile.encoding=${file.encoding}</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>${maven-jar-plugin.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The zfoo 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
|
||||
*
|
||||
* http://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.zfoo.boot;
|
||||
|
||||
import com.zfoo.event.EventContext;
|
||||
import com.zfoo.event.schema.EventRegisterProcessor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author jaysunxiao
|
||||
* @version 3.0
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class EventAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public EventRegisterProcessor eventRegisterProcessor() {
|
||||
return new EventRegisterProcessor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public EventContext eventContext() {
|
||||
return new EventContext();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The zfoo 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
|
||||
*
|
||||
* http://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.zfoo.boot;
|
||||
|
||||
import com.zfoo.net.NetContext;
|
||||
import com.zfoo.net.config.manager.ConfigManager;
|
||||
import com.zfoo.net.config.model.NetConfig;
|
||||
import com.zfoo.net.consumer.service.Consumer;
|
||||
import com.zfoo.net.dispatcher.manager.PacketDispatcher;
|
||||
import com.zfoo.net.packet.service.PacketService;
|
||||
import com.zfoo.net.session.manager.SessionManager;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author jaysunxiao
|
||||
* @version 3.0
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnBean(NetConfig.class)
|
||||
public class NetAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(NetConfig.class)
|
||||
public ConfigManager configManager(NetConfig netConfig) {
|
||||
var configManager = new ConfigManager();
|
||||
configManager.setLocalConfig(netConfig);
|
||||
return configManager;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public PacketService packetService() {
|
||||
return new PacketService();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public PacketDispatcher packetDispatcher() {
|
||||
return new PacketDispatcher();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public Consumer consumer() {
|
||||
return new Consumer();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SessionManager sessionManager() {
|
||||
return new SessionManager();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public NetContext netContext() {
|
||||
return new NetContext();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The zfoo 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
|
||||
*
|
||||
* http://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.zfoo.boot;
|
||||
|
||||
import com.zfoo.orm.OrmContext;
|
||||
import com.zfoo.orm.manager.OrmManager;
|
||||
import com.zfoo.orm.model.accessor.MongodbAccessor;
|
||||
import com.zfoo.orm.model.config.OrmConfig;
|
||||
import com.zfoo.orm.model.query.MongodbQuery;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author jaysunxiao
|
||||
* @version 3.0
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnBean(OrmConfig.class)
|
||||
public class OrmAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnBean(OrmConfig.class)
|
||||
public OrmManager ormManager(OrmConfig ormConfig) {
|
||||
var ormManager = new OrmManager();
|
||||
ormManager.setOrmConfig(ormConfig);
|
||||
return ormManager;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public MongodbAccessor mongodbAccessor() {
|
||||
return new MongodbAccessor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public MongodbQuery mongodbQuery() {
|
||||
return new MongodbQuery();
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public OrmContext ormContext() {
|
||||
return new OrmContext();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The zfoo 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
|
||||
*
|
||||
* http://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.zfoo.boot;
|
||||
|
||||
import com.zfoo.scheduler.SchedulerContext;
|
||||
import com.zfoo.scheduler.schema.SchedulerRegisterProcessor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author jaysunxiao
|
||||
* @version 3.0
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class SchedulerAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SchedulerRegisterProcessor schedulerRegisterProcessor() {
|
||||
return new SchedulerRegisterProcessor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public SchedulerContext schedulerContext() {
|
||||
return new SchedulerContext();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The zfoo 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
|
||||
*
|
||||
* http://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.zfoo.boot;
|
||||
|
||||
import com.zfoo.storage.StorageContext;
|
||||
import com.zfoo.storage.interpreter.ExcelResourceReader;
|
||||
import com.zfoo.storage.manager.StorageManager;
|
||||
import com.zfoo.storage.model.config.StorageConfig;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author jaysunxiao
|
||||
* @version 3.0
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnBean(StorageConfig.class)
|
||||
public class StorageAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnBean(StorageConfig.class)
|
||||
public StorageManager storageManager(StorageConfig storageConfig) {
|
||||
var storageManager = new StorageManager();
|
||||
storageManager.setStorageConfig(storageConfig);
|
||||
return storageManager;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public ExcelResourceReader excelResourceReader() {
|
||||
return new ExcelResourceReader();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public StorageContext storageContext() {
|
||||
return new StorageContext();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.zfoo.boot.EventAutoConfiguration,\
|
||||
com.zfoo.boot.SchedulerAutoConfiguration,\
|
||||
com.zfoo.boot.StorageAutoConfiguration,\
|
||||
com.zfoo.boot.OrmAutoConfiguration,\
|
||||
com.zfoo.boot.NetAutoConfiguration
|
||||
Reference in new issue
Block a user