重构:按功能初步拆分模块

This commit is contained in:
Charles7c 2022-12-10 21:25:14 +08:00
parent 4ed8ba4709
commit 12b839f297
12 changed files with 264 additions and 92 deletions

View File

@ -15,6 +15,19 @@ ContiNew-Admin (incubating) 中后台管理框架Continue New Admin持续
| [Undertow](https://undertow.io/) | 2.2.20.Final | 采用 Java 开发的灵活的高性能 Web 服务器,提供包括阻塞和基于 NIO 的非堵塞机制。 |
| [Lombok](https://projectlombok.org/) | 1.18.24 | 在 Java 开发过程中用注解的方式,简化了 JavaBean 的编写,避免了冗余和样板式代码,让编写的类更加简洁。 |
### 项目结构
采用按功能拆分模块的开发方式,项目结构如下:
> 项目结构按模块的层次顺序介绍,实际 IDE 中 `continew-admin-common` 模块会因为字母排序原因排在上方
>
```
continew-admin 全局通用项目配置及依赖版本管理
├─continew-admin-webapi API 模块(存放 Controller 层代码,打包部署的模块)
├─continew-admin-system 系统管理模块(存放系统管理模块相关功能,例如:部门管理、角色管理、用户管理等)
├─continew-admin-common 公共模块(存放公共工具类,公共配置等)
```
### License

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
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.
-->
<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>
<parent>
<groupId>top.charles7c</groupId>
<artifactId>continew-admin</artifactId>
<version>${revision}</version>
</parent>
<artifactId>continew-admin-common</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>公共模块(存放公共工具类,公共配置等)</description>
<dependencies>
<!-- ################ Spring Boot 相关 ################ -->
<!-- Spring Boot Web提供 Spring MVC Web 开发能力,默认内置 Tomcat 服务器) -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- 移除内置 Tomcat 服务器 -->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Undertow 服务器(采用 Java 开发的灵活的高性能 Web 服务器,提供包括阻塞和基于 NIO 的非堵塞机制) -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
<!-- 移除 websocket 依赖,后续使用 websocket 可考虑由 Netty 提供。另可解决日志警告UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used -->
<exclusions>
<exclusion>
<groupId>io.undertow</groupId>
<artifactId>undertow-websockets-jsr</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
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.
-->
<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>
<parent>
<groupId>top.charles7c</groupId>
<artifactId>continew-admin</artifactId>
<version>${revision}</version>
</parent>
<artifactId>continew-admin-system</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>系统管理模块(存放系统管理模块相关功能,例如:部门管理、角色管理、用户管理等)</description>
<dependencies>
<!-- 公共模块(存放公共工具类,公共配置等) -->
<dependency>
<groupId>top.charles7c</groupId>
<artifactId>continew-admin-common</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
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.
-->
<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>
<parent>
<groupId>top.charles7c</groupId>
<artifactId>continew-admin</artifactId>
<version>${revision}</version>
</parent>
<artifactId>continew-admin-webapi</artifactId>
<packaging>jar</packaging>
<name>${project.artifactId}</name>
<description>API 模块(存放 Controller 层代码,打包部署的模块)</description>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- 系统管理模块(存放系统管理模块相关功能,例如:部门管理、角色管理、用户管理等) -->
<dependency>
<groupId>top.charles7c</groupId>
<artifactId>continew-admin-system</artifactId>
</dependency>
</dependencies>
<build>
<!-- 设置构建的 jar 包名 -->
<finalName>${project.parent.name}</finalName>
<plugins>
<!-- 单元测试配置插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Dfile.encoding=UTF-8</argLine>
<!-- 根据启用环境执行对应 @Tag 的测试方法 -->
<groups>${profiles.active}</groups>
<!-- 排除标签 -->
<excludedGroups>exclude</excludedGroups>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- 如果没有该项配置devtools 不会生效,应用不会自动重启 -->
<fork>true</fork>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -7,7 +7,7 @@ continew-admin:
# 版本
version: @project.version@
--- ### 日志配置
--- ### 日志配置(重叠部分,优先级高于 logback-spring.xml 中的配置)
logging:
level:
top.charles7c: @logging.level@

View File

@ -55,6 +55,7 @@
<!-- 开发环境:只打印到控制台 -->
<springProfile name="dev">
<!-- 如果配置的日志等级,和 application.yml 中的日志等级配置重叠application.yml 配置优先级高 -->
<root level="INFO">
<appender-ref ref="CONSOLE"/>
</root>
@ -63,6 +64,7 @@
<!-- 生产环境:只输出到文件 -->
<springProfile name="prod">
<root level="INFO">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="ASYNC_FILE"/>
</root>
</springProfile>

149
pom.xml
View File

@ -19,6 +19,21 @@ limitations under the License.
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>
<groupId>top.charles7c</groupId>
<artifactId>continew-admin</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<description>ContiNew-Admin (incubating) 中后台管理框架Continue New Admin持续以最新流行技术栈构建。</description>
<url>https://github.com/Charles7c/continew-admin</url>
<modules>
<module>continew-admin-webapi</module>
<module>continew-admin-system</module>
<module>continew-admin-common</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
@ -26,16 +41,9 @@ limitations under the License.
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>top.charles7c</groupId>
<artifactId>continew-admin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>ContiNew-Admin (incubating) 中后台管理框架Continue New Admin持续以最新流行技术栈构建。</description>
<url>https://github.com/Charles7c/continew-admin</url>
<properties>
<!-- ### 基础环境相关 ### -->
<revision>0.0.1-SNAPSHOT</revision>
<java.version>1.8</java.version>
<spotless.version>2.28.0</spotless.version>
<maven.compiler.source>8</maven.compiler.source>
@ -43,34 +51,34 @@ limitations under the License.
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!-- 全局依赖版本管理 -->
<dependencyManagement>
<dependencies>
<!-- ################ 本项目子模块相关 ################ -->
<!-- API 模块(存放 Controller 层代码,打包部署的模块) -->
<dependency>
<groupId>top.charles7c</groupId>
<artifactId>continew-admin-webapi</artifactId>
<version>${project.version}</version>
</dependency>
<!-- 系统管理模块(存放系统管理模块相关功能,例如:部门管理、角色管理、用户管理等) -->
<dependency>
<groupId>top.charles7c</groupId>
<artifactId>continew-admin-system</artifactId>
<version>${project.version}</version>
</dependency>
<!-- 公共模块(存放公共工具类,公共配置等) -->
<dependency>
<groupId>top.charles7c</groupId>
<artifactId>continew-admin-common</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- ################ Spring Boot 相关 ################ -->
<!-- Spring Boot Web提供 Spring MVC Web 开发能力,默认内置 Tomcat 服务器) -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- 移除内置 Tomcat 服务器 -->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Undertow 服务器(采用 Java 开发的灵活的高性能 Web 服务器,提供包括阻塞和基于 NIO 的非堵塞机制) -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
<!-- 移除 websocket 依赖,后续使用 websocket 可考虑由 Netty 提供。另可解决日志警告UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used -->
<exclusions>
<exclusion>
<groupId>io.undertow</groupId>
<artifactId>undertow-websockets-jsr</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
@ -84,12 +92,6 @@ limitations under the License.
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Lombok在 Java 开发过程中用注解的方式,简化了 JavaBean 的编写,避免了冗余和样板式代码,让编写的类更加简洁) -->
<dependency>
<groupId>org.projectlombok</groupId>
@ -99,28 +101,12 @@ limitations under the License.
</dependencies>
<build>
<!-- 设置构建的 jar 包名 -->
<finalName>${project.name}</finalName>
<plugins>
<!-- 代码等格式化插件 -->
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>${spotless.version}</version>
<configuration>
<java>
<importOrder>
<order>java,javax,org,com,top.charles7c,</order>
</importOrder>
<removeUnusedImports/>
<eclipse>
<file>${project.basedir}/code-style/spotless-formatter.xml</file>
</eclipse>
<licenseHeader>
<file>${project.basedir}/code-style/license-header</file>
</licenseHeader>
</java>
</configuration>
<executions>
<execution>
<phase>compile</phase>
@ -129,38 +115,19 @@ limitations under the License.
</goals>
</execution>
</executions>
</plugin>
<!-- 单元测试配置插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Dfile.encoding=UTF-8</argLine>
<!-- 根据启用环境执行对应 @Tag 的测试方法 -->
<groups>${profiles.active}</groups>
<!-- 排除标签 -->
<excludedGroups>exclude</excludedGroups>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- 如果没有该项配置devtools 不会生效,应用不会自动重启 -->
<fork>true</fork>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
<java>
<importOrder>
<order>java,javax,org,com,top.charles7c,</order>
</importOrder>
<removeUnusedImports/>
<eclipse>
<file>code-style/spotless-formatter.xml</file>
</eclipse>
<licenseHeader>
<file>code-style/license-header</file>
</licenseHeader>
</java>
</configuration>
</plugin>
</plugins>
@ -171,7 +138,7 @@ limitations under the License.
<includes>
<include>**/**</include>
</includes>
<!-- 启用过滤,即该资源中的变量将会被替换 -->
<!-- 启用过滤,即替换对应资源中的变量 -->
<filtering>true</filtering>
</resource>
</resources>
@ -185,7 +152,7 @@ limitations under the License.
<!-- Spring Boot 启用环境 -->
<profiles.active>dev</profiles.active>
<!-- 日志级别 -->
<logging.level>debug</logging.level>
<logging.level>DEBUG</logging.level>
<!-- 日志存储位置 -->
<logging.file.path>./logs</logging.file.path>
</properties>
@ -198,7 +165,7 @@ limitations under the License.
<id>prod</id>
<properties>
<profiles.active>prod</profiles.active>
<logging.level>info</logging.level>
<logging.level>INFO</logging.level>
<logging.file.path>./logs</logging.file.path>
</properties>
</profile>