Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.3k views
in Technique[技术] by (71.8m points)

SpringBoot不同的模块有两个启动类,我希望启动其中一个另外一个也启动,请问怎么实现?

我现在有两个模块,abbott-system模块和abbott-generator模块

我的模块abbott-system有url为/exp/list 模块abbott-generator有url为/article/list,我希望启动模块abbott-system后,b模块的abbott-generator为/article/list也有效,请问怎么实现呢?abbott-system模块和abbott-generator使用不同的端口号

——————————————
如果不用下面的方法怎么解决上面的问题
——————————————
我希望启动AbbottApplication后,GeneratorApplication也可以启动

——————————————

abbott-system模块

http://127.0.0.1:9091/abo/exp/findAll

这是url可以被访问到

我的启动函数在这个模块下

abbott-generator模块

http://127.0.0.1:9090/aggregation/v1?start=0&dataLength=100

这是url访问不到

abbott-system 模块

package cn;

//import cn.spring.inter.config.CorsFilter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;


/**
 * 默认 SpringBoot 会扫描主类所在包 及子包下组件
 */
@SpringBootApplication
//@ComponentScan(basePackages= {"cn.spring.inter.controller"})//扫描组件
//@EntityScan("cn.spring.inter.bean")
//@EnableJpaRepositories("cn.spring.inter.repository")
//@MapperScan({"cn.spring.inter.*.Mapper","org.example.*.mapper"})
public class AbbottApplication {
    public static void main(String[] args) {
        SpringApplication.run(AbbottApplication.class, args);
    }

}

abbott-generator 模块

package com.abbott;

@SpringBootApplication
public class GeneratorApplication {
    public static void main(String[] args) {
        SpringApplication.run(GeneratorApplication.class, args);
        System.out.println("start GeneratorApplication");
    }
}

父模块POM

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.web</groupId>
    <artifactId>abbott-admin</artifactId>
    <packaging>pom</packaging>
    <version>1.0</version>
    <name>ABBOTT 后台管理系统</name>
    <url>http://maven.apache.org</url>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.0.RELEASE</version>
    </parent>

    <!-- 注意:加入子模块 -->
    <modules>
        <module>abbott-common</module>
        <module>abbott-generator</module>
        <module>abbott-system</module>
    </modules>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <log4jdbc.version>1.16</log4jdbc.version>
        <swagger.version>2.9.2</swagger.version>
        <fastjson.version>1.2.70</fastjson.version>
        <druid.version>1.1.22</druid.version>
        <java.version>1.8</java.version>
    </properties>


    <dependencies>
        <!-- 提供了web模块的依赖  -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- Spring boot websocket -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-websocket</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </dependency>
        <!-- 热部署  -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>
        <!-- fastjson -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>${fastjson.version}</version>
        </dependency>
        <!--mysql数据库驱动-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.11</version>
        </dependency>
        <!--mybatis-->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.xmlunit</groupId>
            <artifactId>xmlunit-core</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.session</groupId>
            <artifactId>spring-session-core</artifactId>
        </dependency>

    </dependencies>


</project>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

通过执行dos命令或者shell脚本 你想启动多少个就启动多少个


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...