SpringBoot 分模块开发的操作方法

网友投稿 372 2022-08-06


SpringBoot 分模块开发的操作方法

1、在原项目新增一个maven模块

选 maven ,不要选 spring initializr不然会覆盖掉原项目

2、新增的maven模块会出现在项目中,选配置pom文件

xmlns:xsi="http://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 的依赖

ruoyi //parent项目中不存放任何代码,只是管理多个项目之间公共的依赖,即项目最外部的那个POM

com.ruoyi

3.8.1

4.0.0

stone //模块名称

//引用其它模块或组件,开发时用的到

com.ruoyi

ruoyi-common

xmlns:xsi="http://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 的依赖

ruoyi //parent项目中不存放任何代码,只是管理多个项目之间公共的依赖,即项目最外部的那个POM

com.ruoyi

3.8.1

4.0.0

stone //模块名称

//引用其它模块或组件,开发时用的到

com.ruoyi

ruoyi-common

3、在父项目POM中加上新增模块的配置

com.ruoyi

ruoyi-common

${ruoyi.version}

//这里添加新增的模块

stone

ruoyi-admin

ruoyi-framework

ruoyi-system

ruoyi-quartz

ruoyi-generator

ruoyi-common

stone //这里注明引入的是模块

4、在主启动模块中引用模块

com.ruoyi

ruoyi-generator

//主启动模块这里也加上去

&http://lt;dependency>

com.ruoyi

stone

3.8.1

5、在主模块中配置SpringBoot的包扫描,使Controller可以用起来

@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })

@ComponentScan(basePackages = {"com.ruoyi.*","com.ruoyi.stone.*"}) //这里需加入包扫描,否则启用不了新增模块里面的控制器等方法

public class RuoYiApplication

{

public static void main(String[] args)

{

// System.setProperty("spring.devtools.restart.enabled", "false");

SpringApplication.run(RuoYiApplication.class, args);


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Java 深入浅出讲解泛型与包装类(java史莱姆娘模组)
下一篇:教你创建springcloud微服务的基础子服务的超详细过程(springboot+springcloud微服务开发实战)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~