欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

SpringBoot?分模塊開發(fā)的操作方法

 更新時間:2022年04月02日 09:55:05   作者:好大一只雞  
這篇文章主要介紹了SpringBoot?分模塊開發(fā)的操作方法,通過在原項目新增一個maven模塊,本文通過示例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下

1、在原項目新增一個maven模塊

選 maven ,不要選 spring initializr不然會覆蓋掉原項目

2、新增的maven模塊會出現(xiàn)在項目中,選配置pom文件

<?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>                             //各個子項目,需要添加對parent 的依賴
        <artifactId>ruoyi</artifactId>   //parent項目中不存放任何代碼,只是管理多個項目之間公共的依賴,即項目最外部的那個POM
        <groupId>com.ruoyi</groupId>
        <version>3.8.1</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
 
    <artifactId>stone</artifactId>  //模塊名稱
    <dependencies>
        <!-- 通用工具-->   //引用其它模塊或組件,開發(fā)時用的到
        <dependency>
            <groupId>com.ruoyi</groupId>
            <artifactId>ruoyi-common</artifactId>
        </dependency>
    </dependencies>
</project>

 3、在父項目POM中加上新增模塊的配置

           <!-- 通用工具-->
            <dependency>
                <groupId>com.ruoyi</groupId>
                <artifactId>ruoyi-common</artifactId>
                <version>${ruoyi.version}</version>
            </dependency>
 
            <!-- stone-->  //這里添加新增的模塊
                <artifactId>stone</artifactId>
        </dependencies>
    </dependencyManagement>
    <modules>
        <module>ruoyi-admin</module>
        <module>ruoyi-framework</module>
        <module>ruoyi-system</module>
        <module>ruoyi-quartz</module>
        <module>ruoyi-generator</module>
        <module>ruoyi-common</module>
        <module>stone</module>  //這里注明引入的是模塊
    </modules>

4、在主啟動模塊中引用模塊

        <!-- 代碼生成-->
        <dependency>
            <groupId>com.ruoyi</groupId>
            <artifactId>ruoyi-generator</artifactId>
        </dependency>
        <!-- stone-->  //主啟動模塊這里也加上去
        <dependency>
            <groupId>com.ruoyi</groupId>
            <artifactId>stone</artifactId>
            <version>3.8.1</version>
        </dependency>
    </dependencies>

 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);

到此這篇關(guān)于SpringBoot 分模塊開發(fā)的文章就介紹到這了,更多相關(guān)SpringBoot 分模塊開發(fā)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論