添加启动模块,方便管理开发的api接口,将api接口统一管理在该模块中。
1、新建一个Module模块
2、拷贝ruoyi-admin模块pom.xml下相关依赖:
去掉计划任务、自动生成代码、添加ruoyi-system模块的引用
<dependencies>
<!-- spring-boot-devtools -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!-- 表示依赖不会传递 -->
</dependency>
<!-- swagger3-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
</dependency>
<!-- 防止进入swagger页面报类型转换错误,排除3.0.0中的引用,手动增加1.6.2版本 -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.6.2</version>
</dependency>
<!-- Mysql驱动包 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- 核心模块-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-framework</artifactId>
</dependency>
<!-- 系统模块-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-system</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.5.15</version>
<configuration>
<fork>true</fork> <!-- 如果没有该配置,devtools不会生效 -->
</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>
3、根目录pom.xml添加ruoyi-api模块的引用
<!-- 前端接口-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-api</artifactId>
<version>${ruoyi.version}</version>
</dependency>
4、拷贝ruoyi-admin模块下resources到ruoyi-api模块下
5、修改application.yml端口,例如:9090
6、在java资源包下新建com.ruoyi目录,拷贝RuoYiServletInitializer和RuoYiApplication至该目录下并修改名称,例如:ApiServletInitializer和ApiApplication
7、在com.ruoyi包下创建config目录并拷贝ruoyi-admin模块com.ruoyi.web.core.config目录下SwaggerConfig至该目录
8、启动