学习SpringBoot+Vue前后端分离项目,原项目GitHub地址,项目作者江雨一点雨博客。
找到maven的settings.xml
-<profile>
<id>jdk-1.8</id>
-<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
-<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
先关闭项目左上角-文件-关闭项目到如下图所示界面,再进入项目工程文件夹,删除除了src和pom.xml外的所有文件,并更改文件夹名为vhr-web
进入pom.xml,修改下面这两处为vhr-web
创建maven新项目vhr,不选骨架直接点下一步,创建模块vhrserver,父工程为vhr
继续添加vhr-mapper、vhr-service、vhr-model,注意此时父工程为vhrserver
关闭项目,在vhr文件夹中保留vhrserver、src和pom.xml,在vhrserver文件夹中保留vhr-mapper、vhr-service、vhr-model和pom.xml,然后在各个模块文件夹中保留src和pom.xml,最后将vhr-web剪切到vhrserver中。
打开项目,在vhr-web的pom.xml中,右键单击,选择Add as Maven Project
将其中的parent标签剪切到vhr的pom.xml中
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
给vhr-web添加parent
<parent>
<artifactId>vhrserver</artifactId>
<groupId>org.javaboy</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
在vhrserver中添加module
<module>vhr-web</module>
给vhr-mapper/pom.xml添加vhr-model依赖
<dependencies>
<dependency>
<groupId>org.javaboy</groupId>
<artifactId>vhr-model</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
给vhr-service/pom.xml添加vhr-mapper依赖
<dependencies>
<dependency>
<groupId>org.javaboy</groupId>
<artifactId>vhr-mapper</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
给vhr-web/pom.xml添加vhr-service依赖
<dependency>
<groupId>org.javaboy</groupId>
<artifactId>vhr-service</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
将vhr-web/pom.xml中的spring-boot-starter-security依赖剪切到vhr-service和vhr-model
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
</dependencies>
将vhr-web/pom.xml中的spring-boot-starter-web依赖剪切到vhr-model中
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
将vhr-web/pom.xml中的poi依赖剪切到vhr-service中
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.1</version>
</dependency>
将vhr-web/pom.xml中的数据库相关的两个依赖剪切到vhr-mapper中
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.21</version>
</dependency>
在vhr-mapper/pom.xml中添加
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml
接下来在各模块创建org.javaboy.vhr,这样是为了对应之前写的文件内的路径,然后将vhr-web中的service、mapper、utils、model分到对应模块中
重新启动项目,启动前端,测试登录。