若依框架新建子模块
若依框架新建子模块。
·
第一步:新建业务模块目录,例如:ruoyi-test
第二步:在ruoyi-test业务模块下新建pom.xml文件以及src\main\java,src\main\resources目录
<?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>ruoyi</artifactId>
<groupId>com.ruoyi</groupId>
<version>x.x.x</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ruoyi-test</artifactId>
<description>
测试模块
</description>
<dependencies>
<!-- 通用工具-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common</artifactId>
</dependency>
</dependencies>
</project>
第三步:根目录pom.xml依赖声明节点dependencies中添加依赖
<!-- 测试模块-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-test</artifactId>
<version>${ruoyi.version}</version>
</dependency>
第四步:根目录pom.xml模块节点modules添加业务模块
<module>ruoyi-test</module>
第五步:ruoyi-admin目录pom.xml添加模块依赖
<!-- 测试模块-->
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-test</artifactId>
</dependency>
第六步:在ruoyi-test测试模块添加com.ruoyi.test.controller包,新建MyTestController.java
package com.ruoyi.test.controller;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.AjaxResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@RestController
@RequestMapping("/test")
public class MyTestController {
/**
* 输出hellow word
* @param response
* @return
* @throws IOException
*/
@Anonymous
@GetMapping("/printHellowWord")
public AjaxResult demo(HttpServletResponse response) throws IOException
{
AjaxResult ajax = AjaxResult.success();
ajax.put("str", "hellow word");
return ajax;
}
}
访问http://localhost:8080/test/printHellowWord,输出:
更多推荐
已为社区贡献1条内容
所有评论(0)