From e21a7d965727f6707355af98177f5b630090c3e7 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Thu, 8 Dec 2022 23:50:42 +0800 Subject: [PATCH] first commit --- .gitignore | 41 +++++ LICENSE | 21 +++ README.md | 21 +++ pom.xml | 141 ++++++++++++++++++ .../charles7c/ContinewAdminApplication.java | 48 ++++++ src/main/resources/application-dev.yml | 5 + src/main/resources/application-prod.yml | 5 + src/main/resources/application.yml | 48 ++++++ src/main/resources/banner.txt | 8 + src/main/resources/logback-spring.xml | 69 +++++++++ .../ContinewAdminApplicationTests.java | 13 ++ 11 files changed, 420 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 pom.xml create mode 100644 src/main/java/top/charles7c/ContinewAdminApplication.java create mode 100644 src/main/resources/application-dev.yml create mode 100644 src/main/resources/application-prod.yml create mode 100644 src/main/resources/application.yml create mode 100644 src/main/resources/banner.txt create mode 100644 src/main/resources/logback-spring.xml create mode 100644 src/test/java/top/charles7c/ContinewAdminApplicationTests.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..41e8fa52 --- /dev/null +++ b/.gitignore @@ -0,0 +1,41 @@ +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/ + +### Temp ### +*.log +*.logs +*.cache +*.diff +*.patch +*.tmp \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..2f73ac21 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright © 2022-present Charles7c + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 00000000..ec00f984 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# ContiNew-Admin 中后台管理框架 + +![SNAPSHOT](https://img.shields.io/badge/SNAPSHOT-v0.0.1-%23ff3f59.svg) +[![License](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/Charles7c/continew-admin/blob/dev/LICENSE) + +### 简介 + +ContiNew-Admin (incubating) 中后台管理框架,Continue New Admin,持续以最新流行技术栈构建。当前阶段采用的技术栈:Spring Boot 等。 + +### 技术栈 + +| 名称 | 版本 | 简介 | +| ----------------------------------------------------- | ------- | ------------------------------------------------------------ | +| [Spring Boot](https://spring.io/projects/spring-boot) | 2.7.6 | 简化新 Spring 应用的初始搭建以及开发过程。 | +| [Lombok](https://projectlombok.org/) | 1.18.24 | 在 Java 开发过程中用注解的方式,简化了 JavaBean 的编写,避免了冗余和样板式代码,让编写的类更加简洁。 | + + +### License + +- 遵循 [MIT](https://github.com/Charles7c/continew-admin/blob/dev/LICENSE) 开源许可协议 +- Copyright © 2022-present Charles7c \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..53df4ff0 --- /dev/null +++ b/pom.xml @@ -0,0 +1,141 @@ + + + 4.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 2.7.6 + + + + top.charles7c + continew-admin + 0.0.1-SNAPSHOT + + ${project.artifactId} + ContiNew-Admin (incubating) 中后台管理框架,Continue New Admin,持续以最新流行技术栈构建。 + https://github.com/Charles7c/continew-admin + + + + 1.8 + 8 + 8 + UTF-8 + + + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + + org.springframework.boot + spring-boot-configuration-processor + true + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + org.projectlombok + lombok + true + + + + + + ${project.name} + + + org.apache.maven.plugins + maven-surefire-plugin + + -Dfile.encoding=UTF-8 + + ${profiles.active} + + exclude + + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + + + + true + + + org.projectlombok + lombok + + + + + + + + + src/main/resources + + **/** + + + true + + + + + + + dev + + + + dev + + debug + + ./logs + + + + true + + + + prod + + prod + info + ./logs + + + + diff --git a/src/main/java/top/charles7c/ContinewAdminApplication.java b/src/main/java/top/charles7c/ContinewAdminApplication.java new file mode 100644 index 00000000..704e2a62 --- /dev/null +++ b/src/main/java/top/charles7c/ContinewAdminApplication.java @@ -0,0 +1,48 @@ +package top.charles7c; + +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.core.env.Environment; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.net.InetAddress; + +/** + * 启动程序 + * + * @author Charles7c + * @since 2022/12/8 23:15 + */ +@Slf4j +@RestController +@SpringBootApplication +public class ContinewAdminApplication { + + private static Environment env; + + @SneakyThrows + public static void main(String[] args) { + SpringApplication application = new SpringApplication(ContinewAdminApplication.class); + ConfigurableApplicationContext context = application.run(args); + + env = context.getEnvironment(); + log.info("------------------------------------------------------"); + log.info("{} backend service started successfully.", env.getProperty("continew-admin.name")); + log.info("后端 API 地址:http://{}:{}", InetAddress.getLocalHost().getHostAddress(), env.getProperty("server.port")); + log.info("------------------------------------------------------"); + } + + /** + * 访问首页提示 + * + * @return / + */ + @GetMapping("/") + public String index() { + return String.format("%s backend service started successfully.", env.getProperty("continew-admin.name")); + } +} diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml new file mode 100644 index 00000000..1f311327 --- /dev/null +++ b/src/main/resources/application-dev.yml @@ -0,0 +1,5 @@ +--- ### 服务器配置 +server: + # HTTP 端口(默认 8080) + port: 8000 + diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml new file mode 100644 index 00000000..a6a5ae5b --- /dev/null +++ b/src/main/resources/application-prod.yml @@ -0,0 +1,5 @@ +--- ### 服务器配置 +server: + # HTTP 端口(默认 8080) + port: 18000 + diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 00000000..e34adaf4 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,48 @@ +--- ### 项目配置 +continew-admin: + # 名称 + name: ContiNew-Admin + # 应用名称 + appName: @project.name@ + # 版本 + version: @project.version@ + +--- ### 日志配置 +logging: + level: + top.charles7c: @logging.level@ + file: + path: @logging.file.path@ + config: classpath:logback-spring.xml + +--- ### 服务器配置 +server: + servlet: + # 应用访问路径 + context-path: / + +--- ### Spring 配置 +spring: + application: + name: ${continew-admin.appName} + ## 环境配置 + profiles: + # 启用的环境 + # 配合 Maven Profile 选择不同配置文件进行启动,在 IntelliJ IDEA 右侧 Maven 工具窗口可以快速切换环境 + active: @profiles.active@ + ## JSON 配置 + jackson: + # 时区配置 + time-zone: GMT+8 + # 日期格式化 + date-format: yyyy-MM-dd HH:mm:ss + # 序列化配置(Bean -> JSON) + serialization: + # 是否格式化输出 + indent_output: false + # 忽略无法转换的对象 + fail_on_empty_beans: false + # 反序列化配置(JSON -> Bean) + deserialization: + # 忽略 JSON 中不存在的属性 + fail_on_unknown_properties: false \ No newline at end of file diff --git a/src/main/resources/banner.txt b/src/main/resources/banner.txt new file mode 100644 index 00000000..46cee066 --- /dev/null +++ b/src/main/resources/banner.txt @@ -0,0 +1,8 @@ + ____ _ _ _ _ _ _ _ + / ___| ___ _ __ | |_ (_)| \ | | ___ __ __ / \ __| | _ __ ___ (_) _ __ + | | / _ \ | '_ \ | __|| || \| | / _ \\ \ /\ / /_____ / _ \ / _` || '_ ` _ \ | || '_ \ + | |___| (_) || | | || |_ | || |\ || __/ \ V V /|_____|/ ___ \| (_| || | | | | || || | | | + \____|\___/ |_| |_| \__||_||_| \_| \___| \_/\_/ /_/ \_\\__,_||_| |_| |_||_||_| |_| + + :: ${continew-admin.name} :: v${continew-admin.version} + :: Spring Boot :: v${spring-boot.version} diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml new file mode 100644 index 00000000..1bc082ef --- /dev/null +++ b/src/main/resources/logback-spring.xml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + ${LOG_CHARSET} + + + + + + + ${FILE_LOG_PATTERN} + ${LOG_CHARSET} + + + + + ${LOG_PATH}/%d{yyyy-MM-dd, aux}/${APP_NAME}.%d{yyyy-MM-dd_HH}.%i.log + + 240 + + 20MB + + + + + + + 0 + + 512 + + + + + + + + + + + + + + + + + + diff --git a/src/test/java/top/charles7c/ContinewAdminApplicationTests.java b/src/test/java/top/charles7c/ContinewAdminApplicationTests.java new file mode 100644 index 00000000..5773aa61 --- /dev/null +++ b/src/test/java/top/charles7c/ContinewAdminApplicationTests.java @@ -0,0 +1,13 @@ +package top.charles7c; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class ContinewAdminApplicationTests { + + @Test + void contextLoads() { + } + +}