若依RuoYi-Vue 新建模块

pom.xml(ruoyi)修改

            <dependency>
                <groupId>com.ruoyi</groupId>
                <artifactId>ruoyi-common</artifactId>
                <version>${ruoyi.version}</version>
            </dependency>

            <dependency>
                <groupId>com.ruoyi</groupId>
                <artifactId>xxx-xxx-xxx</artifactId>
                <version>${ruoyi.version}</version>
            </dependency>
<module>ruoyi-common</module>
<module>xxx-xxx-xxx</module>

添加新模块坐标


pom.xml(ruoyi-admin)修改

        <dependency>
            <groupId>com.ruoyi</groupId>
            <artifactId>xxx-xxx-xxx</artifactId>
        </dependency>

新模块pom.xml(xxx-xxx-xxx)

RuoYi-Vue 项目中新增 Web 模块,通常涉及模块的创建、依赖的引入以及配置文件的设置。以下是具体的操作步骤和代码示例: ### 创建新的 Web 模块 1. **定义模块结构** 首先,在项目的 `pom.xml` 文件中添加一个新的模块,并将其定义为 `jar` 类型,以便后续引入相关依赖。在 `pom.xml` 中添加以下内容: ```xml <modules> <module>ruoyi-web</module> <module>ruoyi-new-module</module> <!-- 新增模块名称 --> </modules> ``` 2. **创建模块目录** 在项目的目录结构中,创建一个新的模块文件夹,例如 `ruoyi-new-module`,并在其中添加 `pom.xml` 文件。该文件中应包含模块的基本配置,例如: ```xml <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>com.ruoyi</groupId> <artifactId>ruoyi</artifactId> <version>3.8.0</version> </parent> <artifactId>ruoyi-new-module</artifactId> <packaging>jar</packaging> <dependencies> <!-- Web 相关 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- 其他需要的依赖 --> </dependencies> </project> ``` ### 引入必要的依赖 根据项目的实际需求,可以在模块的 `pom.xml` 文件中引入相关的依赖项。例如,如果需要引入安全模块、数据库模块等,可以添加以下依赖: ```xml <!-- Security 相关 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <!-- MyBatis 相关 --> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.2.0</version> </dependency> ``` ### 配置模块 1. **配置文件** 在模块的 `resources` 目录下,创建 `application.yml` 或 `application.properties` 文件,用于配置模块的运行参数。例如: ```yaml server: port: 8081 spring: datasource: url: jdbc:mysql://localhost:3306/your_database username: root password: root driver-class-name: com.mysql.cj.jdbc.Driver ``` 2. **启动类** 创建一个启动类,确保模块能够独立运行。例如: ```java @SpringBootApplication public class RuoYiNewModuleApplication { public static void main(String[] args) { SpringApplication.run(RuoYiNewModuleApplication.class, args); } } ``` 3. **控制器** 在模块中创建一个简单的控制器类,用于处理 Web 请求。例如: ```java @RestController @RequestMapping("/api") public class SampleController { @GetMapping("/hello") public String sayHello() { return "Hello from RuoYi-New-Module!"; } } ``` 通过上述步骤,可以在 RuoYi-Vue 项目中成功创建一个新的 Web 模块,并为其配置必要的依赖和功能[^4]。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值