本文最后更新于:2023年4月2日 晚上
由于自己新做了个项目练手,先设计完了门户网站首页,需要设计相应后端服务,不过之前搭建的忘了存模板,这次重新搭建一次顺便记录一下。搭建的SpringBoot项目时基于若依前后端分离框架实现的,在原有基础上选择性修改。
开发工具:IntelliJ IDEA 2021.3.3 (Ultimate Edition)
若依框架分离版:RuoYi-Vue: 🎉 基于SpringBoot,Spring Security,JWT,Vue & Element 的前后端分离权限管理系统,同时提供了 Vue3 的版本 (gitee.com)
初始化项目
创建项目

选择一些必要的依赖,这里的Spring Boot的版本提供的都是高版本的,在创建项目后直接在pom.xml文件中修改版本号,我这里选用的是2.2.13.RELEASE版本
创建完后的项目目录

根据自己的需要修改了POM文件,印象里只记得只有添加没有删除若依框架原有的依赖
pom.xml文件
demo
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
| <?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>
<groupId>com.qingyu</groupId> <artifactId>demo</artifactId> <packaging>pom</packaging> <version>1.0.0</version>
<modules> <module>qingyu-common</module> <module>qingyu-system</module> <module>qingyu-core</module> <module>qingyu-admin</module> <module>qingyu-quartz</module> <module>qingyu-generator</module> <module>qingyu-web</module> </modules>
<properties> <qingyu.version>1.0.0</qingyu.version> <java.version>1.8</java.version> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <maven-jar-plugin.version>3.6.3</maven-jar-plugin.version> <druid.version>1.2.12</druid.version> <bitwalker.version>1.21</bitwalker.version> <swagger.version>3.0.0</swagger.version> <kaptcha.version>2.3.2</kaptcha.version> <pagehelper.boot.version>1.3.1</pagehelper.boot.version> <oshi.version>5.8.0</oshi.version> <jna.version>5.8.0</jna.version> <commons.io.version>2.11.0</commons.io.version> <commons.fileupload.version>1.4</commons.fileupload.version> <commons.collections.version>3.2.2</commons.collections.version> <poi.version>4.1.2</poi.version> <velocity.version>1.7</velocity.version> <jwt.version>0.9.1</jwt.version> <hutool.version>5.7.21</hutool.version> <fastjson.version>1.2.74</fastjson.version> <jackson.version>2.10.5</jackson.version> <lombok.version>1.18.24</lombok.version> <mybatis-plus.version>3.5.2</mybatis-plus.version> </properties>
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>2.2.13.RELEASE</version> <type>pom</type> <scope>import</scope> <exclusions> <exclusion> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-to-slf4j</artifactId> </exclusion> </exclusions> </dependency>
<dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> <version>${druid.version}</version> </dependency>
<dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>${mybatis-plus.version}</version> </dependency>
<dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>${lombok.version}</version> </dependency>
<dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-bom</artifactId> <version>${hutool.version}</version> <type>pom</type> <scope>import</scope> </dependency>
<dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>${fastjson.version}</version> </dependency>
<dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>${jackson.version}</version> </dependency>
<dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>${pagehelper.boot.version}</version> <exclusions> <exclusion> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-to-slf4j</artifactId> </exclusion> </exclusions> </dependency>
<dependency> <groupId>eu.bitwalker</groupId> <artifactId>UserAgentUtils</artifactId> <version>${bitwalker.version}</version> </dependency>
<dependency> <groupId>com.github.oshi</groupId> <artifactId>oshi-core</artifactId> <version>${oshi.version}</version> </dependency>
<dependency> <groupId>net.java.dev.jna</groupId> <artifactId>jna</artifactId> <version>${jna.version}</version> </dependency>
<dependency> <groupId>net.java.dev.jna</groupId> <artifactId>jna-platform</artifactId> <version>${jna.version}</version> </dependency>
<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> <version>${swagger.version}</version> <exclusions> <exclusion> <groupId>io.swagger</groupId> <artifactId>swagger-models</artifactId> </exclusion> </exclusions> </dependency>
<dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>${commons.io.version}</version> </dependency>
<dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>${commons.fileupload.version}</version> </dependency>
<dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>${poi.version}</version> </dependency>
<dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity</artifactId> <version>${velocity.version}</version> <exclusions> <exclusion> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> </exclusion> </exclusions> </dependency>
<dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> <version>${commons.collections.version}</version> </dependency>
<dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt</artifactId> <version>${jwt.version}</version> </dependency>
<dependency> <groupId>com.github.penggle</groupId> <artifactId>kaptcha</artifactId> <version>${kaptcha.version}</version> </dependency>
<dependency> <groupId>com.qingyu</groupId> <artifactId>qingyu-core</artifactId> <version>${qingyu.version}</version> </dependency> <dependency> <groupId>com.qingyu</groupId> <artifactId>qingyu-system</artifactId> <version>${qingyu.version}</version> </dependency> <dependency> <groupId>com.qingyu</groupId> <artifactId>qingyu-common</artifactId> <version>${qingyu.version}</version> </dependency> </dependencies> </dependencyManagement>
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>${java.version}</source> <target>${java.version}</target> <encoding>${project.build.sourceEncoding}</encoding> </configuration> </plugin> </plugins> </build>
<repositories> <repository> <id>public</id> <name>aliyun nexus</name> <url>https://maven.aliyun.com/nexus/content/groups/public</url> <releases> <enabled>true</enabled> </releases> </repository> </repositories>
<pluginRepositories> <pluginRepository> <id>public</id> <name>aliyun nexus</name> <url>https://maven.aliyun.com/nexus/content/groups/public</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories>
</project>
|
这是若依文档中提供的项目结构说明
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| com.ruoyi ├── common // 工具类 │ └── annotation // 自定义注解 │ └── config // 全局配置 │ └── constant // 通用常量 │ └── core // 核心控制 │ └── enums // 通用枚举 │ └── exception // 通用异常 │ └── filter // 过滤器处理 │ └── utils // 通用类处理 ├── framework // 框架核心 │ └── aspectj // 注解实现 │ └── config // 系统配置 │ └── datasource // 数据权限 │ └── interceptor // 拦截器 │ └── manager // 异步处理 │ └── security // 权限控制 │ └── web // 前端控制 ├── ruoyi-generator // 代码生成(可移除) ├── ruoyi-quartz // 定时任务(可移除) ├── ruoyi-system // 系统代码 ├── ruoyi-admin // 后台服务 ├── ruoyi-xxxxxx // 其他模块
|
我只把framework模块名称改为了core,接下来就是创建相应模块、添加依赖坐标,我根据自己的需要增加了前台模块,其他一致。即上面pom.xml文件中子工程声明处。
创建新模块,先删除掉src文件夹

第一步选择创建maven模块


按照这个步骤重复将其余模块全部创建,以下是相应模块的pom.xml文件
添加完依赖坐标,出现许多依赖识别不了没有导入的情况,如图

清了缓存,换了maven,换了镜像源,重新导了又导都没解决。最后发现父工程demo中依赖那里少加了标签,加上之后就正常了,浅记一下惨痛的教训。遇到这种情况,思路是确定maven配置没有问题、POM文件格式是否有问题(大概率是这种情况),其次就是缓存没有按最新的POM文件加载依赖(这种的重新导入一下就行了)。
附:Maven中标签的作用
使用dependencyManagement可以统一管理项目中依赖包的版本号,当需要变更版本号时只需在父pom中修改即可;如果某个子项目需要指定一个特殊的版本号时,只需要在自己项目的pom.xml中显示声明一个版本号即可,此时子项目会使用自己声明的版本号,而不继承父项目的版本号
common
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
| <?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> <parent> <artifactId>demo</artifactId> <groupId>com.qingyu</groupId> <version>1.0.0</version> </parent>
<artifactId>qingyu-common</artifactId>
<description> common通用工具模块 </description>
<dependencies> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </dependency>
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> </dependency>
<dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> </dependency>
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> </dependency>
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional> </dependency>
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency>
<dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> </dependency>
<dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> </dependency>
<dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency>
<dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> </dependency>
<dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> </dependency>
<dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> </dependency>
<dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> </dependency>
<dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> </dependency>
<dependency> <groupId>org.yaml</groupId> <artifactId>snakeyaml</artifactId> </dependency>
<dependency> <groupId>io.jsonwebtoken</groupId> <artifactId>jjwt</artifactId> </dependency>
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-redis</artifactId> </dependency>
<dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-pool2</artifactId> </dependency>
<dependency> <groupId>eu.bitwalker</groupId> <artifactId>UserAgentUtils</artifactId> </dependency>
<dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> </dependency>
<dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-core</artifactId> </dependency>
<dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-http</artifactId> </dependency>
<dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-captcha</artifactId> </dependency>
<dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-jwt</artifactId> </dependency>
<dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-extra</artifactId> </dependency> </dependencies>
</project>
|
system
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| <?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> <parent> <artifactId>demo</artifactId> <groupId>com.qingyu</groupId> <version>1.0.0</version> </parent>
<artifactId>qingyu-system</artifactId>
<description> 系统模块 </description>
<dependencies> <dependency> <groupId>com.qingyu</groupId> <artifactId>qingyu-common</artifactId> </dependency> </dependencies>
</project>
|
core
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| <?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> <parent> <artifactId>demo</artifactId> <groupId>com.qingyu</groupId> <version>1.0.0</version> </parent>
<artifactId>qingyu-core</artifactId>
<description>> 框架核心模块 </description>
<dependencies>
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-to-slf4j</artifactId> </exclusion> </exclusions> </dependency>
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId> </dependency>
<dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> </dependency>
<dependency> <groupId>com.github.penggle</groupId> <artifactId>kaptcha</artifactId> <exclusions> <exclusion> <artifactId>javax.servlet-api</artifactId> <groupId>javax.servlet</groupId> </exclusion> </exclusions> </dependency>
<dependency> <groupId>com.github.oshi</groupId> <artifactId>oshi-core</artifactId> </dependency>
<dependency> <groupId>com.qingyu</groupId> <artifactId>qingyu-system</artifactId> </dependency>
</dependencies>
</project>
|
generator
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| <?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"> <parent> <artifactId>demo</artifactId> <groupId>com.qingyu</groupId> <version>1.0.0</version> </parent> <modelVersion>4.0.0</modelVersion>
<artifactId>qingyu-generator</artifactId>
<description> 代码生成模块 </description>
<dependencies> <dependency> <groupId>org.apache.velocity</groupId> <artifactId>velocity</artifactId> </dependency>
<dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> </dependency>
<dependency> <groupId>com.qingyu</groupId> <artifactId>qingyu-common</artifactId> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter</artifactId> </dependency> <dependency> <groupId>io.swagger</groupId> <artifactId>swagger-annotations</artifactId> <version>1.6.2</version> <scope>compile</scope> </dependency> </dependencies>
</project>
|
quartz
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| <?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> <parent> <artifactId>demo</artifactId> <groupId>com.qingyu</groupId> <version>1.0.0</version> </parent>
<artifactId>qingyu-quartz</artifactId>
<description> 定时模块 </description> </project>
|
admin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
| <?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> <parent> <artifactId>demo</artifactId> <groupId>com.qingyu</groupId> <version>1.0.0</version> </parent>
<artifactId>qingyu-admin</artifactId>
<description> 后台系统模块:web服务入口 </description>
<dependencies> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> </dependency>
<dependency> <groupId>io.swagger</groupId> <artifactId>swagger-models</artifactId> <version>1.6.2</version> </dependency>
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency>
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-to-slf4j</artifactId> </exclusion> </exclusions> </dependency>
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency>
<dependency> <groupId>com.qingyu</groupId> <artifactId>qingyu-core</artifactId> </dependency>
<dependency> <groupId>com.qingyu</groupId> <artifactId>qingyu-quartz</artifactId> <version>1.0.0</version> </dependency>
<dependency> <groupId>com.qingyu</groupId> <artifactId>qingyu-generator</artifactId> <version>1.0.0</version> </dependency> </dependencies>
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.1.1.RELEASE</version> <configuration> <fork>true</fork> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>3.1.0</version> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> <warName>${project.artifactId}</warName> </configuration> </plugin> </plugins> <finalName>${project.artifactId}</finalName> </build>
</project>
|
web
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| <?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> <parent> <artifactId>demo</artifactId> <groupId>com.qingyu</groupId> <version>1.0.0</version> </parent>
<artifactId>qingyu-web</artifactId>
<description> web模块 </description>
<dependencies> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> </dependency>
<dependency> <groupId>io.swagger</groupId> <artifactId>swagger-models</artifactId> <version>1.6.2</version> </dependency>
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency>
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-to-slf4j</artifactId> </exclusion> </exclusions> </dependency>
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency>
<dependency> <groupId>com.qingyu</groupId> <artifactId>qingyu-core</artifactId> </dependency>
<dependency> <groupId>com.qingyu</groupId> <artifactId>qingyu-quartz</artifactId> <version>1.0.0</version> </dependency>
<dependency> <groupId>com.qingyu</groupId> <artifactId>qingyu-generator</artifactId> <version>1.0.0</version> </dependency> </dependencies>
</project>
|
简单画了一下模块之间的依赖关系

到此项目构建完成,在admin模块和web模块中添加包、启动类、配置文件

copy文件
对比若依框架中的启动类,没有添加RuoYiServletInitializer这个类,据了解这个是打war包或部署在web容器中需要的。配置文件一致,具体参数修改为自己的,日志配置文件做了修改。其他模块同样将相应文件添加到自己命名的包路径下。因为我多了个web模块,所以调整了部分文件位置,admin模块就指定了扫描路径。
总结
这里说是搭建springboot项目,实际上也可以说是从0搭建若依框架,不过这里的“0”是指创建项目从零开始,实际上各功能是直接用的若依框架的,如果从造轮子开始整个工程量是很大的。对我这个小白来说就先做到这一步了,等能力足够的时候再平地起高楼。根据自己的需要,我对数据库表字段也做了一些更改,比如部门、岗位这部分不需要,相关的代码和数据库数据都删除了,还有主键我换成了int型,对我像开发的项目来说int就够了,long类型太浪费。除了若依框架,这里还要推荐我最早接触的一个开源项目
蘑菇博客: 蘑菇博客(MoguBlog),一个基于微服务架构的前后端分离博客系统。Web端使用Vue + Element , 移动端使用uniapp和ColorUI。后端使用Spring cloud + Spring boot + mybatis-plus进行开发,使用 Jwt + Spring Security做登录验证和权限校验,使用ElasticSearch和Solr作为全文检索服务,使用Github Actions完成博客的持续集成,使用ELK收集博客日志,文件支持上传七牛云和Minio,支持Docker Compose脚本一键部署。 (gitee.com)
其中web模块的日志文件就是用的陌溪大佬的。
做这个的目的在于增加熟练度、加深印象、熟悉项目的构建流程,web应用请求-响应的流程,虽然很早之前就做过了,但重来一遍还是遇到很多没讲过的报错。最后我会把去除了部门和岗位部分的后端代码放到gitee上,希望能帮助到跟我一样的小白吧,如果哪里写得不对的,欢迎来讨论。
demo-1: 不含部门、岗位信息 (gitee.com)