Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于模块管理的小建议 #143

Open
icefery opened this issue Feb 28, 2021 · 2 comments
Open

关于模块管理的小建议 #143

icefery opened this issue Feb 28, 2021 · 2 comments

Comments

@icefery
Copy link

icefery commented Feb 28, 2021

建议同时采用聚合和继承,使用<dependencyManagement> 管理 spring-boot-dependencies,这样可以更方便的管理 SpringBoot 版本,也方便约束一些其它包(比如 mybatis-plus-boot-starter )的版本,

比如/spring-boot-examples/pom.xml

<project>
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>spring-boot-examples</artifactId>
    <version>2.0.0</version>
    <packaging>pom</packaging>

    <modules>
        <module>spring-boot-redis</module>
    </modules>

    <properties>
        <java.version>11</java.version>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>2.3.7.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>

/spring-boot-examples/spring-boot-redis/pom.xml

<project >
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.example</groupId>
        <artifactId>spring-boot-examples</artifactId>
        <version>2.0.0</version>
    </parent>

    <artifactId>spring-boot-redis</artifactId>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>
</project>
@superkuang1997
Copy link

模块管理还是很重要。
有很多包阿里镜像没有,想改一下版本发现每个模块的依赖都是独立的,很尴尬。
最后只能开代理从官方仓库中下载解决。

@JxJPu9bD
Copy link

JxJPu9bD commented Sep 7, 2021

是的, 如果 spring-boot-examples 下没有 pom 还好, 既然选择了 module 还是完善更好些.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants